Java Magazine, Jan/Feb 2016
ORACLE COM JAVAMAGAZINE JANUARY FEBRUARY 2016 88 microservices docker build t trains ui f ui Dockerfile docker build t trains routes f routes Dockerfile docker build t trains bookings f bookings Dockerfile Once built these images can be run anywhere Docker or the Docker API is used as well as anywhere Docker Swarm Kubernetes various PaaS providers and many such services are used To test the images we can run them locally We also need to start a ZooKeeper instance by using an existing image Dont forget to pass the required environment variables to our microservices using the e switch The following example uses 17217421 as the Docker host because that is the default Adjust as needed docker run p 2181 2181 d fabric8 zookeeper docker run name ui p 3000 8080 d e BASE_ URI http 17217421 3000 e ZOOKEEPER_ URI 17217421 2181 trains ui docker run name routes p 3001 8080 d e BASE_ URI http 17217421 3001 e ZOOKEEPER_ URI 17217421 2181 trains routes docker run name bookings p 3002 8080 d e BASE_ URI http 17217421 3002 e ZOOKEEPER_ URI 17217421 2181 trains bookings We can now browse our microservice application at http localhost 3000 or browse our REST services for the routes and bookings modules at http localhost 3001 and http localhost 3002 respectively Conclusion In this article we have seen how to develop microservices with standard Java EE using the open source KumuluzEE framework As demonstrated the KumuluzEE framework automates tasks related to the configuration and deployment of microservices With simple dependency definitions in Maven it allows us to create self contained standalone JAR files which contain the required execution environment Therefore they can be executed within a standard JRE without requiring an application server This way microservices with KumuluzEE provide a minimal footprint and are a good fit for executing in cloud PaaS and Docker style environments which was demonstrated with this example We also saw how to handle service discovery using ZooKeeper KumuluzEE is an enabler for a microservices architecture in Java EE The major benefit is that it allows us to use standard Java EE APIs to develop microservices This way we can also port existing applications to microservices Although at first blush microservices might look odd to traditional app server developers many technologists believe microservices represent the future of Java in the cloud Feel free to download KumuluzEE and try it out article Tilen Faganel is lead software architect at Sunesis He is the lead developer of the KumuluzEE framework for Java which won the 2015 Dukes Choice Award for best Java innovation Matjaz B Juric PhD is a Java Champion and Oracle ACE Director who has authored or coauthored more than 15 books on Java BPM and SOA and published in several magazines and journals learn more Getting Started with KumuluzEE
You must have JavaScript enabled to view digital editions.