Kevin Sutter, Senior Technical Staff Member, IBM @kwsutter
Alasdair Nottingham, Websphere Runtime Architect, IBM @notatibm
The move to microservices is well under way, but has enterprise Java adapted to these new realities? Although some argue that enterprise Java is irrelevant, many of its tried-and-proven APIs are highly applicable to microservice architectures. And the need for new APIs to address challenges inherent in highly distributed microservices is clear. The recent announcement of the Micro Profile initiative (microprofile.io) to define new application server portable APIs means that these needs will be addressed. This session explores what Micro Profile is, how it can help with microservices, and how WebSphere Liberty’s à la carte approach to Java EE can help enable microservices by using the new Micro Profile and ldemo Liberty plus the microProfile-1.0 feature.
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Liberty: The Right Fit for Micro Profile?
1. 1IBM
_
Liberty – Right Fit for
MicroProfile
Alasdair Nottingham, IBM, STSM, WebSphere Runtime Architect
Kevin Sutter, IBM, STSM, Java EE Architect
JavaOne Sept 2016
2. JavaOne 2016
Who Are We?
Kevin Sutter
WebSphere Java EE architect
sutter@us.ibm.com
Alasdair Nottingham
WebSphere Liberty architect
alasdair@us.ibm.com
3. 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
4. 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
– …
5. JavaOne 2016
But then, we had an idea!
• What if we had one URL for every
recurring 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
11. 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
13. JavaOne 2016
… that supports rapid development…
• Sparse configuration – intelligent defaults, configure only what you need
• Automating reloading of configuration and applications
14. 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 Profile
0.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.3
34
93
104
46
Startup & Footprint Comparison
of various lightweight servers
Startup time
Footprint
Startuptimeinseconds(LowerisBetter)
FootprintinMB(LowerisBetter)
15. 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…
16. 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
17. 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
18. 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
20. 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?
?
21. 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
28. 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...
29. 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…
30. 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
32. 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…
33. 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
36. 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
39. 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
40. JavaOne 2016
Option 2: SoftLayer
• VMWare on IBM Cloud
• We could host WAS Liberty VMs in the cloud
on
41. 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, …
43. JavaOne 2016
Yay! We’re done!
• Everyone open your phones and go to:
http://meetings.mybluemix.net
44. 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 …
45. 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
49. 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