SlideShare a Scribd company logo
@dandreadis
Turn you Java EE Monoliths
into Microservices with
Dimitris Andreadis
Sr. Engineering Manager
Red Hat JBoss EAP / WildFly
@dandreadis
Once upon a time*
*http://dandreadis.blogspot.ch/2014/10/10-years-on-red-pill.html
@dandreadis
Agenda
● Thinking Microservices
● WildFly Architecture
● WildFly Swarm Concepts
● Getting Started with Swarm
● Advanced Configuration Options
@dandreadis
Let’s talk Microservices
@dandreadis
What are Microservices?
@dandreadis
What are Microservices?
● A bit like SOA (but smaller?)
● Written in any cool programming language
● By (smaller?) two-pizza teams
● Who break monoliths into (small?) services
● That encapsulate fully some (small?) vertical application aspect
● And run them independently in their own (smaller?) containers
Did I say small?
@dandreadis
Why do Microservices?
1) Because everyone else does it
2) Because you have to go internet scale
3) Because you want to deliver fast
@dandreadis
You Must Be This Tall*
● Self-Service, On Demand, Elastic Infrastructure as code
● Deployment Independence
● Full stack Ownership
● Dev vs Ops
● Automation & Immutability
● CI/CD pipeline
● Agile Delivery
*thanks Burr Shutter for letting me steal your slide :)
@dandreadis
Simpler services but more complex environments
*source: wikibon.com/evolving-container-arhitectures
@dandreadis
“Rolling out Microservices
requires some sort of a
Distributed Application Server” *
*Dimitris Andreadis, Voxxed Athens, May 2017
@dandreadis
@dandreadis
“Right Size” the Runtime
@dandreadis
JBoss “Innovation” ca. 2001
● Collapse the EJB and Servlet
layer in a single VM to avoid
x100 slower remote calls!
● No need to actively code for
remote call failure either :)
@dandreadis
A tiny bit of WildFly Architecture
@dandreadis
WildFly* pre-History
*the server once called JBoss Application Server
@dandreadis
Kernel Taxonomy
● JBoss AS 2.x, 3.x, 4.x
– JMX MicroKernel
● JBoss AS 5.x, 6.x
– JBoss MicroContainer
● AS7.x, WildFly 8.x, 9.x, 10.x
– JBoss Modules &
Modular Service Container
Turn you Java EE Monoliths into Microservices with WildFly Swarm
Java EE7 Full & Web
distribution (134 Mb)
standalone/
configuration/
configuration.xml
Servlet-Only
distribution (28 Mb)
standalone/
configuration/
configuration.xml
Turn you Java EE Monoliths into Microservices with WildFly Swarm
@dandreadis
WildFly
"the Swiss Army
Knife of Runtimes”
@dandreadis
Welcome to WildFly Swarm
@dandreadis
What is WildFly Swarm?
● WildFly Broken Apart
– Decompose and reconstruct WildFly
around your application
– Just enough app-server for your Microservice
packaged into an UberJar
– With additional functionality outside Java EE
like NetflixOSS libraries, etc.
● Part of the JBoss / Red Hat ecosystem
@dandreadis
Rightsize your Runtime around your App
@dandreadis
Plus a lot more components!
● Keycloak (SSO)
● Hystrix (Circuit Breaker)
● Ribbon (client side LB)
● Vert.x (reactive)
● Undertow (web server)
● Camel (integration)
● Hashicorp Consul (discovery)
● Swagger (service contracts)
● LogStash (log aggregation)
● and more...
@dandreadis
Why WildFly Swarm?
● Leverage your Java EE expertise
● Build on mature technologies
and a scalable runtime
● Be part of the future of Java EE
and help shape it for the Cloud
@dandreadis
@dandreadis
Self-contained (Uber) Jar
● bundles your application,
● the Fractions to support it,
● an internal Maven repository with
the dependencies,
● and Bootstrap code.
● There is also the notion of a
Hollow launch-pad type of jar.
@dandreadis
Concept of a Fraction
● WildFly Swarm compositional units
● Providing specific runtime capabilities
● And different means to configure them
– with reasonable default
@dandreadis
Fractions
● Enable WildFly subsystems (e.g. Infinispan)
● Integrate additional frameworks/services (e.g. Topology)
● Provide deployments (e.g. Swagger, Jolokia)
● Add API dependencies (e.g. JAX-RS)
● Alter deployments (e.g. SSO)
@dandreadis
Fractions (cont.)
● Expressed as Maven (GAV) coordinates:
– org.wildfly.swarm:<fraction>:<version>, e.g
– org.wildfly.swarm:undertow:2017.05.0
● 169 fractions currently available
– 148 stable
– 15 unstable
– 6 experimental
● More in the pipeline
@dandreadis
Where do I start?
http://wildfly-swarm.io/generator/
@dandreadis
@dandreadis
demo.zip (1kb)
├── pom.xml
└── src
└── main
└── java
└── com
└── example
└── demo
└── rest
└── HelloWorldEndpoint.java
@dandreadis
HelloWorldEndpoint.java
@dandreadis
How is WildFly Swarm enabled?
@dandreadis
● mvn package
demo-swarm.jar
...
_bootstrap/demo.war
m2repo/<fractions & modules jars>
modules/<bootstrap-modules.xml
<bootstrap-classes>
...
Build
@dandreadis
Run
● java -jar demo-swarm.jar
● mvn wildfly-swarm:run
● IDE > Run o.w.s.Swarm
● IDE > Run … MyMain
@dandreadis
java -jar target/demo-swarm.jar
@dandreadis
@dandreadis
Auto-detecting Fractions
● Absence of dependencies
triggers fractionDetectMode
@dandreadis
JAXRS fraction selected
Bean Validation, CDI, CDI-Config, Transactions, JAX-RS w.
JAXB, JAX-RS w. JSON-P, Microprofile fractions removed
@dandreadis
How Fractions are configured?
● Default configuration with sensible defaults
● System properties to override common settings
● standalone.xml or a fragment of it can override settings
- or -
● Take control of main() and use the fluent Java API
– Covers all WildFly subsystems
– Generated from the WF configuration schema
@dandreadis
Taking control of main()
@dandreadis
Setup JDBC driver and Datasource
@dandreadis
Environment specific configuration
./src/main/resources/project-stages.yml
logger:
level: DEBUG
database:
jdbc:
url: foo
---
project:
stage: development
logger:
level: DEBUG
database:
jdbc:
url: bar
---
project:
stage: production
logger:
level: INFO
database:
jdbc:
url: somethingElse
@dandreadis
Resources
● wildfly-swarm.io
● github.com/wildfly-swarm
● @wildflyswarm
● irc: #wildfly-swarm
● www.wildfly.org
● github.com/wildfly
● @wildflyAS
● wildfly.org/joinus
wildfly-swarm.gitbooks.io/wildfly-swarm-users-guide/
@dandreadis
Thanks!

More Related Content

Turn you Java EE Monoliths into Microservices with WildFly Swarm