Microservices with Wildfly Swarm and Infinispan
Everybody loves Microservices, right?
Today, all of us have slightly different understanding what Microservices are but, among all those definitions and attributes, there’s probably one thing that fits them all - they need to be simple.
So let’s have a look at some practical example of creating a REST service with Infinispan as a storage wired together using CDI. We will use Wildfly Swarm as a running platform.
A good way to start a new Wildfly Swarm project is to generate it. The only requirement here is to add "JAX-RS with CDI" and "JPA" as dependencies.
The next step is to add infinispan-embedded artifact. The final pom.xml should look like the following:
Infinispan CDI Extension will take care of bootstrapping Infinispan, so we can dive directly into JAX-RS code:
And that’s it!
If you’d like to have a look at the complete example, check out my repository. The code is based on fresh build from Infinispan master branch which contains lots of improvements for CDI. You might build it yourself or just wait for 9.0.0.Beta1.
Have a lot of fun with Microservices!