Home United States USA — software Java EE MicroProfile With KumuluzEE Java EE MicroProfile With KumuluzEE

Java EE MicroProfile With KumuluzEE Java EE MicroProfile With KumuluzEE


Despite MicroProfile’s hype, KumuluzEE already offers service discovery, registration, and configuration support for microservices in a Java EE environment.
Enterprise Java seems to be a step back from the others when it comes to microservices architecture. Some weeks ago, I took a part in Code Europe – the programming conference in Warsaw. One of the speakers was Ivar Grimstad, who was talking about MicroProfile – an open initiative for optimizing Enterprise Java for a microservices architecture. This idea is very interesting, but at the moment, it is rather at the beginning of the road.
However, while I was reading about the microprofile initiative, I came across information about JavaEE framework developed by Slovenian company – KumuluzEE. The solution seemed to be interesting enough that I decided to take a closer look at it. Well, we can read on the website that KumuluzEE is the Java Duke’s Choice Award Winner, so there is still a hope for JavaEE and microservices
We should also add some KumuluzEE dependencies to the Maven pom.xml .
To enable service registration, we should add one additional dependency to our pom.xml. I chose Consul as a registration and discovery server, but you can also use etcd (kumuluzee-discovery-consul) .
Here’s the account microservice’s main class. As you probably guess, the annotation @RegisterService enables registration on the server.
We start the application by running:
java -cp target/classes; target/dependency/* com.kumuluz.ee. EeApplication
There is one pretty cool thing about discovery with KumuluzEE. As you can see in the @DiscoverService, we can specify a version and environment for account-service instance. The version and environment for the microservice is read automatically from the config.yml during registration in discovery server. So, we can maintain many versions of a single microservice and freely invoke them from other microservices. Requests are automatically load balanced between all microservice match conditions from the annotation @ServiceDiscovery.
To enable KumuluzEE Config, include the Consul implementation by adding the following dependency to your pom.xml .
I do not use a Consul agent running on the localhost, so I need to override some properties in config.yml. I also defined one configuration property, blacklist:
Here’s the class that loads the configuration properties and enables dynamic updates on any change in the configuration source by declaring @ConfigValue (watch = true) on a property.
We use the configuration property blacklist in the resource class for filtering all accounts by blacklisted ids.
Creating microservices with KumuluzEE is pretty easy. I showed you the main capabilities of this framework. KumulezEE has also modules for circuit breakers with Hystrix, streaming with Apache Kafka, and security with OAuth2/OpenID. I will keep a close eye on this library, and I hope it will continue to be developed.

Continue reading...