HollowJAR

Not only in the of Microservices, the actual business logic changes often, but the libraries not related to the business logic do not. Such a concept is very well-known in the domain of operating systems, where common libraries are not only installed once to conserve space on the persistent storage (typically a hard drive) but are also loaded once into memory to achieve the same amount for savings. Java EE implementation libraries, MicroProfile libraries, or even Spring Framework libraries are in the very same relation to Java Microservices or applications in general. These common libraries, changes occur much less often than changes that are done in the internal business logic of an application built by using the common libraries. The libraries are updatable, interchangeable, and distributable in a complete separation from the actual Microservice. 

In RedHat, they made it possible for a Java EE Microservice to create a separate runtime environment and only deploy the application to that environment. This way, one of the biggest disadvantages of monolithic solutions is removed:

  • Fast redeploys 
  • Small distribution overhead
  • Layering principle is not broken
  • Fast changes in Docker images

The libraries representing the actual runtime environment for a Microservice are hollow, as there is no Microservice or application added to the JAR. This is where the name hollow jar originates. WildFly Swarm makes it easy to create such artifacts with just enough dependencies to run a Microservice, but without the actual Microservice inside. To produce a HollowJAR with WildFly Swarm, simply set the -Dswarm.hollow=true Maven property before the application is built by Maven. Or add the <hollow>true</hollow> option to the WildFly Swarm plugin configuration in pom.xml. WildFly Swarm will detect this property and produce a separate JAR with the hollowswarm.jar suffix in Maven's target/ folder.

In order to deploy an application to the hollow environment, simply pass the application's name as an argument:

java -jar weather-service-hollowjar.jar weather-service.war
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.142.166