Easy integration of Bluemix services with your applications

29
© 2015 IBM Corporation Easy Integration of Bluemix Services with Your Applications Junjie Cai Bluemix runtime lead architect

Transcript of Easy integration of Bluemix services with your applications

© 2015 IBM Corporation

Easy Integration of Bluemix Services with Your Applications Junjie Cai

Bluemix runtime lead architect

Agenda

• Bluemix overview

• Using resource services in your Java web app

• Using operational services for your Java web app

• How it works

1

New Models of Engagement Systems of Record

Data & Transaction Integrity Smarter Devices & Assets

• Data & Transactions

• App Infrastructure

• Virtualized Resources

• Expanding Interface Modalities

• Big Data and Analytics

• Social Networking

Next Generation

Architectures

New models of product & service innovation are emerging

2

Bluemix was built from the ground up with a user-based and design-centric approach.

It addresses these personas and key needs.

Our users include novice,

born-on-the-cloud, and

enterprise developers.

Want to compose

applications quickly with

useful APIs, to avoid

tedious backend config.

Expect fast time-to-value,

simplicity, flexibility, clear

documentation.

Failing

Fast

Seconds to

Deploy Friction

Free

Any

Language

Continuous

Integration

Mobile

Ready Focus on

Code

Choice of

Tools

Useful

APIs

Bluemix Goals: Focus on the Cloud & Enterprise Application Developer

3

Bluemix: IBM’s Cloud Platform

• DevOps

• Big Data

• Mobile

• Watson

• Business Analytics

Bluemix service categories

• Database

• Web and application

• Security

• Internet of Things

• Integration

• Containers

• Virtual Machines

Developer experience

• Rapidly deploy and scale

applications in any language.

• Compose applications quickly

with useful APIs and services

and avoid tedious backend

config.

• Realize fast time-to-value with

simplicity, flexibility and clear

documentation.

Enterprise capability

• Securely integrate with existing

on-prem data and systems.

• Choose from flexible

deployment models.

• Manage the full application

lifecycle with DevOps.

• Develop and deploy on a

platform built on a foundation of

open technology. Built on a foundation of open

technology.

Build, run, scale, manage, integrate & secure applications in the cloud

4

Bluemix embraces Cloud Foundry as an open source Platform as a

Service and extends it with IBM, third party, and community built runtime

and services.

How does Bluemix work?

5

The plain way to use a service in Bluemix

Step 1: Create & Bind the service • Command line

– cf marketplace to see available services

– cf create-service to create a service instance

– cf bind-service to bind the service instance to your application

– cf restart, or cf restage/push again

• Web console (see demo)

– View service endpoint and credentials from VCAP_SERVICES environment variable:

6

The plain way to use a service in Bluemix (cont’)

Step 3: Read the credentials & invoke its API

Step 2: Provide the driver jar in your application

Drawbacks:

• Verbose code

• No connection pooling

7

There is an easier way to use these services

Modern “resource”

Operational services

Java EE standard “resource”

8

The Java EE way – Sample code for using SQLDB

9

public class TestServlet extends HttpServlet

{

@Resource (name = "jdbc/mydb") private DataSource db;

...

protected void doGet(HttpServletRequest request, HttpServletResponse

response) throws ServletException, IOException {

// Alternatively, use InitialContext lookup

DataSource lookup = (DataSource) new InitialContext().lookup("jdbc/mydb");

...

}

“mydb” is the name of the service

instance you create in Bluemix

That’s it! All familiar code, no changes required in order to

make it work in cloud! • No need for a server.xml. Appropriate stanzas automatically generated.

• Don’t need to read VCAP_SERVICES

• Don’t need to provide a driver

Using the MQLite service – your familiar way again!

Develop responsive, scalable applications with a fully

managed messaging provider in the cloud. Quickly integrate

with application frameworks through easy to use APIs.

10

public class TestServlet extends HttpServlet

{

@Resource (name = "jms/emq")

private ConnectionFactory cf;

...

protected void doGet(HttpServletRequest request, HttpServletResponse

response) throws ServletException, IOException {

// Alternatively, use InitialContext lookup

ConnectionFactory lookup =

(ConnectionFactory) new InitialContext().lookup(“jms/myemq");

...

}

More “resource” services accessible in the same way

11

MongoDB is an open source document database.

Improve the performance & user experience of web applications

by retrieving information from fast, managed, in-memory

caches, instead of relying entirely on slower disk-based

databases.

Cloudant NoSQL DB provides access to a fully managed

NoSQL JSON data layer that's always on. This service is

compatible with CouchDB, and accessible through a simple to

use HTTP interface for mobile and web application models.

11

Cloudant

public class TestServlet extends HttpServlet

{

@Resource (name = “cloudant/mycloudantdb") private CouchDbInstasnce db;

...

protected void doGet(HttpServletRequest request, HttpServletResponse

response) throws ServletException, IOException {

// Alternatively, use InitialContext lookup

CouchDbInstance db = (CouchDbInstance) new

InitialContext().lookup("cloudant/mycloudantdb");

CouchDbConnector dbc = _db.createConnector(DATABASE, true);

CouchDocument dbentry = new CouchDocument();

dbentry.setContent("testEntry");

dbc.create(dbentry);

}

“mycloudantdb” is the name of the

service instance you create in Bluemix

12

DataCache

public class TestServlet extends HttpServlet

{

@Resource (name = “wxs/myGrid") private ObjectGrid og;

...

protected void doGet(HttpServletRequest request, HttpServletResponse

response) throws ServletException, IOException {

// Alternatively, use InitialContext lookup

ObjectGrid og = (ObjectGrid) new

InitialContext().lookup(“wxs/myGrid");

...

}

“myGrid” is the name of the service

instance you create in Bluemix

13

MongoDB

import com.mongodb.DB;

public class TestServlet extends HttpServlet

{

@Resource (name = “cloudant/mymongo")

private DB db;

...

protected void doGet(HttpServletRequest request, HttpServletResponse

response) throws ServletException, IOException {

// Alternatively, use InitialContext lookup

db = (DB) InitialContext().lookup("cloudant/mymongo");

...

}

“mymongo” is the name of the service

instance you create in Bluemix

14

Using operational services

15

Session Cache

• Improve application resiliency by storing session state information

across many HTTP requests.

• Enable persistence HTTP sessions for your application & seamless

session recovery in event of an application failure.

16

Auto-scaling

• The Auto-Scaling for Bluemix service enables you to automatically

increase or decrease the compute capacity of your application. The

number of application instances are adjusted dynamically based on

the Auto-Scaling policy you define.

17

Metric name Description Supported

application type

CPU The utilization percentage of

the CPU. All

Memory The usage percentage of

the memory. All

JVM heap The usage percentage of

the JVM heap memory. Liberty for Java

Throughput

The number of the

processed requests per

second.

Liberty for Java

Monitoring & Analytics

• Gain the visibility and control you need over your application.

• Determine the response time your users see, understand the

performance and availability of the application components, and

leverage analytics to keep your application up and performing well.

18

Single Sign On

• Implement user authentication for your web and mobile apps quickly,

using simple policy-based configurations.

• Secure apps with confidence, not a lot of coding

• You choose the identity sources and we do the rest

19

New Relic

• New Relic is the all-in-one web app performance tool that lets you

see performance from the end user experience, through servers, and

down to the line of code.

20

Behind the scene – Auto-Configuration Service plugin framework

• Allow service providers to customize runtime configuration

during application staging, triggered by the presence of a

service binding

• Available in both IBM Liberty & Node.js buildpacks

21

Users can also turn off Auto-Configuration and get the control

Disable individual services’ auto-configuration using the

services_autoconfig_excludes environment variable

Use a server package or server folder to take full control of the

server configuration Connection info in runtime-vars.xml as variables

Provide a server.xml that reads these variables

Push a server package or folder

22

Server configuration variables

Variables available via runtime-vars.xml (generated on cloud)

server.xml (you provide)

23

server.xml

...

<dataSource id="db2-mydb" jdbcDriverRef="db2-driver"

jndiName="jdbc/mydb" statementCacheSize="30"

transactional="true">

<properties.db2.jcc id="db2-mydb-props"

databaseName="${cloud.services.mydb.connection.db}"

user="${cloud.services.mydb.connection.username}"

password="${cloud.services.mydb.connection.password}"

portNumber="${cloud.services.mydb.connection.port}"

serverName="${cloud.services.mydb.connection.host}"/>

</dataSource>

...

Import javax.sql.DataSource;

public class MyServlet extends HTTPServlet

{

@Resource(name=“jdbc/somedb”)

private DataSource myDataSource;

… or ….

InitialContext ctx = new InitialContext();

DataSource ds = (DataSource) ctx.lookup(“jdbc/somedb”);

}

1

2

3

• Allows the developer to use a JNDI

name different from the one defined

in server.xml

• Works only if there is a single service

instance defined in server.xml.

Any/all bindings will be auto-wired to

it.

Java EE Resource Auto-wiring for some IBM created Bluemix services

24

25

Security

Services

Web and

application

services

Cloud

Integration

Services

Mobile

Services

Database

services

Big Data

services

Internet of

Things

Services

Watson

Services

DevOps

Services

Summary

• Use the rich set of Bluemix

services as building blocks

to quickly stand up your

applications

• Stick to the “standard” way

to access these “resource”

services, transparent to the

location

• Consume operational

services with just “one

click”

Notices and Disclaimers

Copyright © 2015 by International Business Machines Corporation (IBM). No part of this document may be reproduced or

transmitted in any form without written permission from IBM.

U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with

IBM.

Information in these presentations (including information relating to products that have not yet been announced by IBM) has been

reviewed for accuracy as of the date of initial publication and could include unintentional technical or typographical errors. IBM

shall have no responsibility to update this information. THIS DOCUMENT IS DISTRIBUTED "AS IS" WITHOUT ANY WARRANTY,

EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL IBM BE LIABLE FOR ANY DAMAGE ARISING FROM THE USE OF

THIS INFORMATION, INCLUDING BUT NOT LIMITED TO, LOSS OF DATA, BUSINESS INTERRUPTION, LOSS OF PROFIT

OR LOSS OF OPPORTUNITY. IBM products and services are warranted according to the terms and conditions of the

agreements under which they are provided.

Any statements regarding IBM's future direction, intent or product plans are subject to change or withdrawal without

notice.

Performance data contained herein was generally obtained in a controlled, isolated environments. Customer examples are

presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual

performance, cost, savings or other results in other operating environments may vary.

References in this document to IBM products, programs, or services does not imply that IBM intends to make such products,

programs or services available in all countries in which IBM operates or does business.

Workshops, sessions and associated materials may have been prepared by independent session speakers, and do not

necessarily reflect the views of IBM. All materials and discussions are provided for informational purposes only, and are neither

intended to, nor shall constitute legal or other guidance or advice to any individual participant or their specific situation.

It is the customer’s responsibility to insure its own compliance with legal requirements and to obtain advice of competent legal

counsel as to the identification and interpretation of any relevant laws and regulatory requirements that may affect the customer’s

business and any actions the customer may need to take to comply with such laws. IBM does not provide legal advice or

represent or warrant that its services or products will ensure that the customer is in compliance with any law.

Notices and Disclaimers (con’t)

Information concerning non-IBM products was obtained from the suppliers of those products, their published

announcements or other publicly available sources. IBM has not tested those products in connection with this

publication and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM

products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products.

IBM does not warrant the quality of any third-party products, or the ability of any such third-party products to

interoperate with IBM’s products. IBM EXPRESSLY DISCLAIMS ALL WARRANTIES, EXPRESSED OR IMPLIED,

INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A

PARTICULAR PURPOSE.

The provision of the information contained herein is not intended to, and does not, grant any right or license under any

IBM patents, copyrights, trademarks or other intellectual property right.

• IBM, the IBM logo, ibm.com, Bluemix, Blueworks Live, CICS, Clearcase, DOORS®, Enterprise Document

Management System™, Global Business Services ®, Global Technology Services ®, Information on Demand,

ILOG, Maximo®, MQIntegrator®, MQSeries®, Netcool®, OMEGAMON, OpenPower, PureAnalytics™,

PureApplication®, pureCluster™, PureCoverage®, PureData®, PureExperience®, PureFlex®, pureQuery®,

pureScale®, PureSystems®, QRadar®, Rational®, Rhapsody®, SoDA, SPSS, StoredIQ, Tivoli®, Trusteer®,

urban{code}®, Watson, WebSphere®, Worklight®, X-Force® and System z® Z/OS, are trademarks of

International Business Machines Corporation, registered in many jurisdictions worldwide. Other product and

service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on

the Web at "Copyright and trademark information" at: www.ibm.com/legal/copytrade.shtml.

Thank You Your Feedback is

Important!

Access the InterConnect 2015

Conference CONNECT Attendee

Portal to complete your session

surveys from your smartphone,

laptop or conference kiosk.