This document discusses WildFly Swarm, a tool that packages a Java application together with just the pieces of the WildFly application server runtime that it needs. It allows building self-contained applications that can run independently of any pre-installed server. The document outlines how WildFly Swarm works, how it allows selecting specific Java EE APIs and frameworks, and how it produces a single executable "uber jar" file. It also provides examples of creating a simple REST application using WildFly Swarm and customizing the runtime configuration.
7. @dandreadis
Modular Service Container
● Small, lightweight and efficient (˜230 kb jar)
● Highly concurrent & scalable state machine
● Various start-up modes
– Active, Passive,
Lazy, Never
Concurrent Service ContainerConcurrent Service Container
Service ControllerService Controller
Service RegistryService Registry
Service BuilderService Builder
ServiceService DepsDeps ValueValue ListenersListeners InjectorsInjectors
8. @dandreadis
JBoss Modules
● WF_ROOT/jboss-modules.jar (365 kb)
– Highly Concurrent Classloading
– Fast O(1) dependency resolution
– See only the modules you import
– No need to break open the jars
java -jar jboss-modules.jar -mp <module-path> <module-spec>
20. @dandreadis
Port Reduction using HTTP Upgrade
Only 2 Ports Open by Default
● 8080 – HTTP for Applications
– Upgradable to JNDI, EJB, JMS
● 9990 – HTTP for Management (Console/JSON)
– Upgradable to Native Management API (CLI/JMX)
24. @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
● Using fully automated deployment machinery
● Did I say small?
25. @dandreadis
What Enabled Microservices?
● Elastic infrastructure, a.k.a the Cloud
● Linux Containers (Docker, Rocket, etc.)
● Orchestration Technologies (Kubernetes, Mesos, etc)
● Continuous Integration / Deployment
● The DevOps movement
Caused by the need for Internet Scale
27. @dandreadis
A Word of Caution
● Every remote call will likely
be x100 slower than an
in-VM call
● You need to actively code
for failure when crossing
VMs
● Sharing state needs to be
well thought of (or avoided)
30. @dandreadis
What is WildFly Swarm?
● WildFly Broken Apart
– Decompose and reconstruct WildFly
around your application
– With additional functionality outside Java EE
like NetflixOSS libraries, etc.
– Just enough app-server for your Microservice
packaged into an UberJar
● Part of the JBoss / Red Hat ecosystem
31. @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
Is portability and supportability a thing of the past?
34. @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...
35. @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.
36. @dandreadis
Fractions
● WildFly Swarm compositional units
● Focus on serving specific usecases
● Define dependencies to other Fractions
● Tie together
– Metadata
– WildFly subsystems
– MSC Services
– Modules
– Deployments
37. @dandreadis
Fractions layer on WildFly-Core and
● 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)
38. @dandreadis
Fractions (cont.)
● Expressed as Maven (GAV) coordinates:
– org.wildfly.swarm:<fraction>:<version>, e.g
– org.wildfly.swarm:undertow:2016.10.0
● 83 fractions currently available
– 48 stable
– 35 experimental
● About 50% wrap WildFly components
● More in the pipeline
48. @dandreadis
Auto-detecting Fractions
● Absence of dependencies
triggers fractionDetectMode
● In this example JAXRS is
detected, leaving out Bean
Validation, CDI &
Transactions
● 4.3Mb jar
● 1330ms
boot time
49. @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