Tuesday, 11 October 2016

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.

Bootstrapping new project

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:

Writing some code

Infinispan CDI Extension will take care of bootstrapping Infinispan, so we can dive directly into JAX-RS code:

And that's it!

What's next?

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!


  1. Is it possible to share data between nodes via Infinispan cache? See https://github.com/slaskawi/infinispan-wf-swarm-example/issues/2

  2. The repository has been moved to https://github.com/infinispan-demos/infinispan-wf-swarm-example