Earlier in 2015 Red Hat made initial release of their new project called WildFly Swarm. This solution allows to run JavaEE based applications as microservices. It’s a competitor for many frameworks like Spring-boot or Dropwizard which are used for creating small application based on microservices architecture very fast. The application server now can be embedded into your application jar with all his dependencies or you can deploy your applications war into standalone WildFly application server instance as before. It’s a big step for JavaEE world and I hope that it will silence all people who were complaining about JavaEE fat application servers.
WildFly-Swarm is decomposed into small modules with a good separation of concerns. With those modules we can fit server dependencies to our own requirements. Besides standard modules, there are a few modules which can help you maintaining your applications and integrate them into your environment. For example Jolokia used to exposing JMX data as JSON over HTTP for monitoring purpose or Netflix Ribbon which is for software load balancing. With WildFly-Swarm we have all JavaEE toolkit setup and standardization, which has a big impact on the application maintenance. Additionally, we can test our application using Arquillian adapter, which helps us test code from outside and inside of the running application.
Full modules list :
- Weld (CDI)
- Netflix Ribbon
First we need wildfly-swarm-plugin definition in our pom.xml
1 2 3 4 5 6 7 8 9 10 11 12 13
Our example application will be simple REST resource. That’s why we need JAX-RS dependency only
1 2 3 4
also standard JAX-RS configuration class
1 2 3 4 5 6
and sample resource for testing
1 2 3 4 5 6 7 8 9 10 11 12 13
Running as WAR
For running application we can package our compiled code into WAR and deploy on server or simpy use widly-swarm-plugin
a minimal version of WildFly will be started with only the modules that are needed. Our application is running, now we can test resource url localhost:8080/resources/hello/John
Running as JAR
We have to define main class where we will configure the container and our deployment archives. We are building deployment using ShrinkWrap tool which is open source project for easy creating, importing, exporting and manipulating archives.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Also we need to change packaging type for jar
and additional wildfly-swarm-plugin configuration where we point to our main class
1 2 3
then we get fat jar with all dependencies, which we now run using java -jar command
and check test url localhost:8080/resources/hello/John
For a long time there was no real competitor for Spring Boot. There were a lot of frameworks but none could compete with them in terms like monitoring, maintenance and productivity. I think WildFly-Swarm is future of JavaEE and microservices. Now it’s going to be much simpler to build JavaEE applications for running in the microservices environment.