51
1 IBM _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter, IBM, STSM, Java EE Architect JavaOne Sept 2016

Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

  • Upload
    trantu

  • View
    219

  • Download
    4

Embed Size (px)

Citation preview

Page 1: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

1IBM _

Liberty – Right Fit for MicroProfile

Alasdair Nottingham, IBM, STSM, WebSphere Runtime ArchitectKevin Sutter, IBM, STSM, Java EE ArchitectJavaOne Sept 2016

Page 2: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Who Are We?

Kevin SutterWebSphere Java EE [email protected]

Alasdair NottinghamWebSphere Liberty [email protected]

Page 3: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

What is MicroProfile?

• http://microprofile.io/

• Optimizing Enterprise Java for a Microservices Architecture

• Complements Java EE – not a replacement for Java EE

3

Page 4: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

A long time ago in a country far, far away…

• Our development team has a lot of recurring meetings:– Design issues– Iteration demos

• Everyone dials in ok, but we tend to have a lot of confusion about the e-meeting at the start of every call:

4

Who’s hosting this call anyway?Are we on the primary or

secondary e-meeting today?

Is it lunchtime yet?Has anyone seen Erin today? She’s not online

– Release planning– …

Page 5: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

But then, we had an idea!

• What if we had one URL for everyrecurring meeting?– e.g. http://w3.liberty/meetings/designIssues

• Meeting owner can configure their e-meeting

• Participants notified if it hasn’t started yet, or automatically redirected to the e-meeting

• Anyone can take over the meeting if the owner doesn’t show up

5

Page 6: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

What happens when we’re away…

6

Page 7: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

…and again…

7

Page 8: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

…and again…

8

Page 9: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

…and again…

9

Page 10: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

So where do we start?

• Well, we need an app server…

10

Page 11: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

We want something very simple now…

• Start small, fast, and simple

• Pay only for what your application needs

Feature Manager HTTP Transport Application Manager

servlet jsp

Page 12: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

…that will scale with the needs of our app…

Application ManagerHTTP TransportFeature Manager

jpaservlet

jsp

jsf

jndi jdbc

sessionDatabasemonitor

wab

blueprint

jaxrs

json

restConnector

osgi.jpa

appSecurity

ssl

localConnector beanValidation

ejbLite cdi managedBeans

oauth collectiveMember ldapRegistry webCache

wasJmsClient wasJmsServer

wasJmsSecurityjmsMdb

jaxws

clusterMember

concurrent

wmqJmsClientwsSecurity

mongodb jaxb

collectiveControllerzosSecurity zosTransaction

zosWlm

Page 13: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

… that supports rapid development…• Sparse configuration – intelligent defaults, configure only what you need

• Automating reloading of configuration and applications

Page 14: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

…so we decide to use Liberty

• Java EE Web profile support in ~50 Mb archive• Starts in a couple second and only uses 50 Mb RAM• From lightweight development to the largest production app, Liberty

scales with the requirements of your application

• First 2Gb RAM in production free!

Tomcat 7.0.12 JBoss 7.0 Web Profile

GlassFish 3.1 Web Profile

Liberty Profile0.0

1.0

2.0

3.0

4.0

5.0

6.0

7.0

8.0

9.0

0

20

40

60

80

100

120

1.7

5.3

7.8

2.334

93104

46

Startup & Footprint Comparison of various lightweight servers

Startup timeFootprint

Star

tup

time

in s

econ

ds (L

ower

is B

ette

r)

Foot

prin

t in

MB

(Low

er is

Bet

ter)

Page 15: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Meeting App

Ok, let’s get started!

Database

• Great! … but how do we start building it?• We’re going to need a REST service … some kind of singleton…

Page 16: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Solution: MicroProfile 1.0

• JAX-RS is the Java EE API for creating RESTful web services– We’ll use JAX-RS to expose REST services for the list of meetings, a

particular meeting’s details, and updating both

• CDI (Context and Dependency Injection) provides for simple POJO managed beans– We’ll use CDI managed beans to ensure that we only have a single list of

meetings and users (which can then be injected into other beans)

• JSON-P provides for parsing JSON documents– We’ll use JSON-P for processing the JSON arguments on the JAX-RS

services

microProfile-1.0

Page 17: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Solution: CDI

• CDI (Context and Dependency Injection) provides for simple POJO managed beans

• Included in the Java EE web profile (and microProfile-1.0!)

• We’ll create a managed bean to ensure that we only have a single list of meetings and users (which can then be injected into other beans)

cdi-1.2

Page 18: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Time to code!

• Install the WebSphere Developer Tools from the Eclipse Marketplace

• Supports WAS v7, v8, v8.5, and v9, including Liberty

• Could also use the extended set of tools available in Rational Application Developer or Rational Software Architect

Page 19: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

DemoBuilding a MicroProfile application

Page 20: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Ok, we have a MicroProfile service!

• … or do we? How do we test it?

20

Meeting App

• How do we tell someone how to build the front end?

?

Page 21: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Solution: API Discovery

• Swagger is the defacto standard for documenting REST services

• API Discovery feature adds Swagger support to Liberty

• Merges Swagger from annotations or separate Swagger docs– Documentation!

• Provides API Explorer to browse and test REST services– Testing!

apiDiscovery-1.0

Page 22: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

DemoUsing Swagger to define our API

Page 23: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Ok, now on to the client!

• Trouble is, neither of us are great at web UI

23

Page 24: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Time to call Erin!

24

But I only do microservices now!

Hey Erin, could you throw together a UI for us?

Ok, ok. Try this out…

Page 25: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

DemoThe New UI

Page 26: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Architect intervention

26

Hey, don’t take all the glory! Share the project so I can code too!

I hear you got promoted. Sure you still know how?

L

Page 27: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

DemoSharing code via Git

Page 28: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016 28

Going beyond MicroProfile 1.0…

• The first release of MicroProfile is limited (by design)…

• But, that doesn’t stop us from using additional features available in Liberty...

Page 29: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Problem: Old data lying around…

29

Hey, I just tried the app and it joined me to last week’s e-meeting! It should really clean things up

Well, I guess I *did* say I wanted to code…

Page 30: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Solution: Concurrency Utilities

• Concurrency Utilities is the Java EE API for concurrency and background tasks

• Builds on Java SE concurrency, but supports running within a container/managed thread environment. Context is propagated from the main thread

• We’ll use concurrency utilities to kick off a background task and clean up the meeting URL

concurrent-1.0

Page 31: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

DemoBackground tasks with Concurrency Utilities

Page 32: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Problem: Persisting meeting data

32

While you’re at it, it would be nice if we didn’t have to recreate the meetings every time we restart the server …

‘Nuf said…

Page 33: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Solution: MongoDB

• There are lots of options for persistence: JDBC, JPA, CouchDB, MongoDB, … in this case we just want something simple and pick MongoDB

• We’ll use MongoDB to persist meeting details

mongodb-2.0

Page 34: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

DemoUsing MongoDB for Persistence

Page 35: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Performance concerns

• After some initial use, we notice an awful lot of traffic on the server

35

Page 36: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Solution: WebSockets

• The WebSocket protocol is a standard for efficient, bi-directional communication

• Standardized for Java via WebSocket API and part of the Java EE 7 spec

• We’ll use WebSockets to notify clients when a meeting is started to avoid polling (and, thus, improve performance)

websocket-1.1

Page 37: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

DemoUsing WebSockets

Page 38: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Great, the app is finally complete!

• But where do we want to host the app?

?

Page 39: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Option 1: Liberty server package

• We could use a Liberty server package for deployment

• server package creates archive of config + app + runtime (optional) for redistribution– minify option creates a completely custom server

Page 40: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Option 2: SoftLayer

• VMWare on IBM Cloud

• We could host WAS Liberty VMs in the cloud

on

Page 41: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Option 3: Bluemix

• Bluemix is an open-standards, cloud-based platform for building, managing, and running apps of all types

• Deploy an application artifact (e.g. .war) with minimal direction (e.g. # of instances, memory required) and Bluemix does the rest:– Sets up infrastructure, deploys runtime & artifact, binds services, routes

traffic, …

Page 42: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

DemoProduction on Bluemix

Page 43: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Yay! We’re done!

• Everyone open your phones and go to:

http://meetings.mybluemix.net

Page 44: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

A look back at the hour…

Application, configuration, and even feature changes happen

automatically!

Minimal restarts

Consistent, simple experience for each new feature

mongodbmicroProfile …

Page 45: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Configurability of Liberty

<!-- Enable features --><featureManager>

<feature>microProfile-1.0</feature> <!–- cdi, jaxrs, jsonp -->

<feature>concurrent-1.0</feature> <!–- background tasks --><feature>mongodb-2.0</feature> <!–- persistence --><feature>webSocket-1.1</feature> <!–- performance -->

<!–- make it real... --><feature>appSecurity-2.0</feature> <!–- basic app security --><feature>ssl-1.0</feature> <!–- ssl support -->

</featureManager>

45

Page 46: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

WebSphere Liberty: The Right Fit for MicroProfile and Java EE

http://microprofile.io

http://wasdev.net/accelerate

Page 47: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

MicroProfile 1.0 Released!

Microservice Collaboration and Innovation in the Java Community

microprofilelunch.com, Thursday 11:30am - 2:00pm

Learn more at microprofile.io

MicroProfile BOF, Tuesday 10:30 - 11:30, Hilton Lombard Room(3rd tower, 6th floor)

Page 48: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

48IBM _

Thank You!

Alasdair Nottingham | [email protected] | @notatibmKevin Sutter | [email protected] | @kwsutter

Page 49: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

What we didn’t cover

• Cool things you can do with the config, including variables, references, config dropins, …

• Cool things in the latest release, including the Bluemix service utility, …

• Liberty’s clean API and classloader visibility ensure your applications are portable

• Zero migration ensures our app and configuration will run for years to come

Page 50: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Visit WASdev.net for all things Liberty!

Page 51: Liberty - Right Fit for MicroProfile - RainFocus · PDF fileIBM 1 _ Liberty – Right Fit for MicroProfile Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect Kevin Sutter,

JavaOne 2016

Demos

• JAX-RS & CDI Managed Bean• API-Discovery• Client UI• Git• JSR-236 Concurrency• MongoDB• WebSockets• Publish to Bluemix

51