Oracle application container cloud back end integration using node final

61
OOW 2016: CON 1283 Maarten Smeets Oracle Application Container Cloud Service Back-End Integration Using Node.js

Transcript of Oracle application container cloud back end integration using node final

Page 1: Oracle application container cloud back end integration using node final

OOW 2016: CON 1283

Maarten Smeets

Oracle Application Container Cloud Service Back-End Integration Using Node.js 

Page 2: Oracle application container cloud back end integration using node final

Introduction

• About AMIS– Located in the Netherlands

• About me– Oracle Integration Consultant– Experience with Oracle SOA Suite since 2007– Well certified (SOA, BPM, Java, SQL,

PL/SQL among others)– Author of a lot of blog articles (

http://javaoraclesoa.blogspot.com)

@MaartenSmeetsNL

https://nl.linkedin.com/in/smeetsm

Page 3: Oracle application container cloud back end integration using node final

Agenda

Node.js introduction Backend integration Application Container Cloud What to use for your integration?

Page 4: Oracle application container cloud back end integration using node final

Introducing Node.js

Page 5: Oracle application container cloud back end integration using node final

Node.jsUsing threads is hard

• Concurrency control mechanisms (e.g. locking)

• Coordination over threads (IPC)

• Memory overhead

• Synchronization

• Programming thread safe code is not easy

Page 6: Oracle application container cloud back end integration using node final

What is Node.js

• Node.js uses a single thread!

• Node.js has been createdTo write high-performance servers fast

• Node.js is:– a set of bindings to V8 for non-browser work: sockets, files, etc.– only exposes non-blocking, asynchronous interfaces– only one thread, one call stack (like a browser)– low level features: half-closed TCP connections, TCP throttling, UDP– has killer HTTP support

Node.js architecture

node standard library

node bindings(socket, http, etc)

V8 thread pool(libeio)

event loop(libev)

C/C++JavaScript

Page 7: Oracle application container cloud back end integration using node final

Node.js why should you care?

Page 8: Oracle application container cloud back end integration using node final

Node.jsWhat do they use it for?

“On the server side, our entire mobile software stack is completely built in Node”

“We are moving every product & every site within PayPal to Node”

“We’ve been busy building our next-generation Netflix.com web application using Node”

“MuleSoft's Anypoint platform services are implemented in Node”

Page 9: Oracle application container cloud back end integration using node final

Node.jsIntegration. Overview

POST /myserviceReceive request

ServiceImplementation

Processing inputCreating outputMessage processing

Backend

Front-end connectivityRouting

Back-end connectivity

Flow control

Page 10: Oracle application container cloud back end integration using node final

Node.jsIntegration. Overview

Front-end connectivity• URL handling• HTTP connection handling

Back-end connectivity• Connect to other services• Drivers to access technology

diverse systems• Connection pooling

Drivers / modules such as• Oracle Database• Oracle NoSQL Database• Mongo Database• SOAP and JSON services

WhatFrameworks such as• Express• Hapi• Koa• Sails

• xml2js• node-soap

Message processing

Middleware• Routing• Mapping

Flow control • Async• Promises

How

Page 11: Oracle application container cloud back end integration using node final

Node.jsFrameworks

• Abstraction

• Generic functionality

• Facilitate development

• Drawbacks– Performance cost– Need framework knowledge– Only specific functionality

https://raygun.com/blog/2016/06/node-performance/

raw node koa express restify hapi0

2000

4000

6000

8000

10000

12000

14000

Framework

Req

uest

s pe

r sec

ond

Page 12: Oracle application container cloud back end integration using node final

Node.jsFrameworks: Express.js

• Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.

• Express.js is used in many other popular frameworks like Sails, MEAN, LoopBack

• It is maintained by StrongLoop (IBM).Started in 2009. 191 contributers. 6,823,598 downloads last month *

* Contributers from github.com. Downloads from npmjs.com. Determined 28 aug 2016

Page 13: Oracle application container cloud back end integration using node final

Node.jsWithout framework

var http = require('http');

var server = http.createServer(function (req, res) { if (req.method === 'GET') {

res.end("Hello World"); }});

server.listen(3000);

Page 14: Oracle application container cloud back end integration using node final

Node.jsWith express.js

var express = require('express');var app = express(); app.get('/', function (req, res) { res.send('Hello World');}); app.listen(3000);

Quick and easy

Page 15: Oracle application container cloud back end integration using node final

Node.jsFrameworks: Other

• HapiA rich framework for building applications and services. Configuration is better than code. Business logic must be isolated from the transport layer.Started in 2011 146 contributers 234,103 downloads last month.

• KoaExpressive, light-weight HTTP framework for Node.js to make web applications and APIs more enjoyable to write. Started in 2013 89 contributers 132,790 downloads last month.

• SailsSails is the most popular MVC framework for Node.js. It is designed for building practical, production-ready Node.js apps. Build on top of express. Started in 2012 210 contributers 59,518 downloads last month.

Page 16: Oracle application container cloud back end integration using node final

Node.js Callback hell

Error handling in every callback handler

Nested callbacks

Page 17: Oracle application container cloud back end integration using node final

Node.js Callback hell

Error handling in every callback handler

Nested callbacks

Page 18: Oracle application container cloud back end integration using node final

Node.jsFlow control. Executing in series

• AsyncAsync is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript.

• PromisesA Promise object represents a value that may not be available yet, but will be resolved at some point in the future. It allows you to write asynchronous code in a more synchronous fashion.

• GeneratorsThe Generator object is returned by a generator function and it conforms to both the iterable protocol and the iterator protocol.

Page 19: Oracle application container cloud back end integration using node final

Node.js modulesConvert XML <> JSON

• xml2jsEver had the urge to parse XML? And wanted to access the data in some sane, easy way? Don't want to compile a C parser, for whatever reason? Then xml2js is what you're looking for!

• xml2js uses SAX (Simple API for XML)– Event driven asynchronous processing of XML– Memory friendly

Does not require creating a Document Object Model (DOM) of the XML document in memory

</> {}

Page 20: Oracle application container cloud back end integration using node final

Node.js modulesHow does JSONized SOAP look?

Mind the namespace prefixes!

Page 21: Oracle application container cloud back end integration using node final

Node.js modulesnode-soap

node-soap is a module that offers SOAP support

Page 22: Oracle application container cloud back end integration using node final

Node.js modulesnode-soap

Define the service logic

Load the WSDL

Create the server

Host the webservice

Page 23: Oracle application container cloud back end integration using node final

Node.js and back-end integration

Page 24: Oracle application container cloud back end integration using node final

Database integration with Node.js

Page 25: Oracle application container cloud back end integration using node final

Oracle NoSQL highlights

• Key value pair database

• Dynamic data model

• Transparent load balancing

• Highly scalable

• Options for transactional mechanisms

• Options for eventual consistency

• Built on BerkelyDB

Page 26: Oracle application container cloud back end integration using node final

NoSQL highlights

http://www.oracle.com/technetwork/database/nosqldb/overview/nosql-transactions-497227.html

Transactional mechanisms

Consistency models

Page 27: Oracle application container cloud back end integration using node final

Node.js and NoSQL

Page 28: Oracle application container cloud back end integration using node final

Node.js

Node.js and NoSQL

Application

Node.js

Application

RMI

RMIJSON

Thrift

nosqldb-oraclejs

JVM

NoSQL Java proxy

kvclient

WL/GlassFish/TomcatREST Data Services

(ORDS)

kvclient

Page 29: Oracle application container cloud back end integration using node final

Node.js and MongoDB

BSON

Node.js

Application

mongoose

Page 30: Oracle application container cloud back end integration using node final

Node.js and the Oracle Databasenode-oracledb

• Maintained by Oracle and actively being developed

• Requires Oracle database client software installedApplication Container Cloud already provides this

• Very rich in features and well documented!

https://github.com/oracle/node-oracledb

Node.js

Application

nosqldb-oraclejs

Page 31: Oracle application container cloud back end integration using node final

Node.js and the Oracle Databasenode-oracledb: Features

• Promises, Callbacks and Streams• SQL and PL/SQL execution• REF CURSORs• Large Objects: CLOBs and BLOBs• Oracle Database 12.1 JSON datatype• Query results as JavaScript objects or arrays• Smart mapping between JavaScript and Oracle types

with manual override available• Data binding using JavaScript objects or arrays• Transaction Management• Inbuilt Connection Pool with Queueing• Database Resident Connection Pooling (DRCP)• External Authentication• Row Prefetching• Statement Caching

• Client Result Caching• End-to-end Tracing, Mid-tier Authentication, and

Auditing• Oracle High Availability Features

– Fast Application Notification (FAN)– Runtime Load Balancing (RLB)– Transparent Application Failover (TAF)

Page 32: Oracle application container cloud back end integration using node final

Node.js and the Oracle Databasenode-oracledb: Features

• Promises, Callbacks and Streams• SQL and PL/SQL execution• REF CURSORs• Large Objects: CLOBs and BLOBs• Oracle Database 12.1 JSON datatype• Query results as JavaScript objects or arrays• Smart mapping between JavaScript and Oracle types

with manual override available• Data binding using JavaScript objects or arrays• Transaction Management• Inbuilt Connection Pool with Queueing• Database Resident Connection Pooling (DRCP)• External Authentication• Row Prefetching• Statement Caching

• Client Result Caching• End-to-end Tracing, Mid-tier Authentication, and

Auditing• Oracle High Availability Features

– Fast Application Notification (FAN)– Runtime Load Balancing (RLB)– Transparent Application Failover (TAF)

Page 33: Oracle application container cloud back end integration using node final

Node.js and the Oracle Databasenode-oracledb: Calling PL/SQL

Define bind variables IN

Define bind variables OUT

Call a PL/SQL function

Page 34: Oracle application container cloud back end integration using node final

Node.js and the Oracle Databasenode-oracledb: Connection pooling

Good sample: http://stackoverflow.com/questions/29846188/node-js-express-oracle-connection-pooling-ora-24418-cannot-open-further-sess

Create a connection pool

Grab a connection from the pool and use it

Close when done. Also in case of errors!

Inbuilt queueing

Page 35: Oracle application container cloud back end integration using node final

Node.js and the Oracle DatabaseUsing DRCP with node-oracledb

• Database Resident Connection Pooling (DRCP)

http://www.oracle.com/technetwork/articles/oracledrcp11g-1-133381.pdf

Page 36: Oracle application container cloud back end integration using node final

Node.js and the Oracle DatabaseUsing DRCP with node-oracledb

• On the client:– Set oracledb.ConnectionClass = ‘poolname’– Easy Connect syntax like myhost/sales:POOLED, or by using a tnsnames.ora alias for a connection that contains (SERVER=POOLED)– Set externalAuth to true in getConnection or createPool

• On the database– execute dbms_connection_pool.start_pool(“poolname”);

https://www.youtube.com/watch?v=3p6rutSLlkg

Simple to use

Page 37: Oracle application container cloud back end integration using node final

Node.js and the Oracle DatabasePerformance with node-oracledb

• Make sure you create a connection pool in the right scope to promote re-use

• Consider increasing the LibUV thread pool size. The default is 4. Can be set with environment variable: UV_THREADPOOL_SIZE

• Explicitly release connections to the pool

• Use a resultSet when the number of rows fetched is large

• Consider using DRCPRead: http://docs.oracle.com/database/121/ADFNS/adfns_perf_scale.htm#ADFNS228

Page 38: Oracle application container cloud back end integration using node final

Introducing Application Container Cloud

Page 39: Oracle application container cloud back end integration using node final

Node.jsWhat doesn’t it provide?

• High availability– Clustering capabilities– Load balancer– On demand scaling

• Management and monitoring

• Support

• Provisioning

• Deployment• Patching• Back-end drivers

99.999%

Page 40: Oracle application container cloud back end integration using node final

Node.jsWhat doesn’t it provide?

• High availability– Clustering capabilities– Load balancer– On demand scaling

• Management and monitoring

• Support

• Provisioning /Deployment

• Patching• Back-end drivers

99.999%

Page 41: Oracle application container cloud back end integration using node final

Application Container CloudEnterprise Grade Features for Node.js

Page 42: Oracle application container cloud back end integration using node final

Application Container Cloud ServiceArchitecture

Tenant1

Tenant2

(App 1) (App 2) (App 3)

Load Balancer Database Cloud

Java Cloud

Messaging Cloud

Storage Cloud

Developer Cloud

Customers

< / >

Developers

Page 43: Oracle application container cloud back end integration using node final

Application Container Cloud ServiceEnterprise grade features for Node.js

• On demand scale out/in. Adding/Removing instances

• On demand scale up/down. Adding/Removing memory per instance

• Automatic load balancer configuration

• One click patching

Page 44: Oracle application container cloud back end integration using node final

Application Container Cloud ServiceEnterprise grade features for Node.js

• Easy web interface fordeployments

• Also possible using the API and Developer Cloud Service

Easy!

Page 45: Oracle application container cloud back end integration using node final

Application Container Cloud ServiceEnterprise grade features for Node.js

• Easy web interface for managing configuration

• Including service bindingssuch as database connections

Page 46: Oracle application container cloud back end integration using node final

Application Container Cloud ServiceEnterprise grade features for Node.js

• Browse log files from the webinterface

Page 47: Oracle application container cloud back end integration using node final

Application Container Cloud ServiceEnterprise grade features for Node.js

https://docs.oracle.com/cloud/latest/apaas_gs/APCSR/

Page 48: Oracle application container cloud back end integration using node final

Application Container Cloud ServiceIntegration with Developer Cloud Service

pom.xmlmaven-assembly-pluginassembly.xml

YourApplication.zip

Node.js application

manifest.json

Page 49: Oracle application container cloud back end integration using node final

Application Container Cloud ServiceIntegration with Developer Cloud Service

Page 50: Oracle application container cloud back end integration using node final

Application Container Cloud ServiceIntegration with Developer Cloud Service

Page 51: Oracle application container cloud back end integration using node final

Application Container Cloud ServiceIntegration with Developer Cloud Service

• Build and deploy with Developer Cloud Service

Page 52: Oracle application container cloud back end integration using node final

Application Container Cloud ServiceIntegration with Developer Cloud Service

Page 53: Oracle application container cloud back end integration using node final

Application Container Cloud ServiceIntegration with Developer Cloud Service

Page 54: Oracle application container cloud back end integration using node final

Application Container Cloud ServiceIntegration with Developer Cloud Service

Page 55: Oracle application container cloud back end integration using node final

Application Container Cloud ServiceIntegration with Developer Cloud Service

Page 56: Oracle application container cloud back end integration using node final

Integration: SOA Suite or Node.js?

Page 57: Oracle application container cloud back end integration using node final

Node.js versus SOA Suite

Page 58: Oracle application container cloud back end integration using node final

Node.js versus SOA Suite

SOA Suite

Node.js architecture

node standard library

node bindings(socket, http, etc)

V8 thread pool(libeio)

event loop(libev)

C/C++JavaScript

Node.js

Page 59: Oracle application container cloud back end integration using node final

Integration with Node.js or SOA Suite

• Node.js assets– thin stateless services like microservices– tying simple things together with minimal effort– technology focus: JavaScript + REST/JSON– High performance

• Node.js challenges– no adapters, workflow, …– no wizard driven IDE– requires (a lot of) custom code– no high availability / management / monitoring options

Consider Application Container Cloud to provide those

Page 60: Oracle application container cloud back end integration using node final

Questions

@MaartenSmeetsNL

https://nl.linkedin.com/in/smeetsm

Download sample code athttps://github.com/MaartenSmeets/nodejssamples

Page 61: Oracle application container cloud back end integration using node final