Spring Boot Microservices With Docker (part one)
Join the DZone community and get the full member experience.Join For Free
service oriented architecture (soa) appears to be back in vogue. luckily for most of us, it does not involve large, enterprise, vendor-backed “soa servers”. this time around, microservices are the model.
a microservice is similiar to the “s” in the solid design principals . it is a service that has only one single responsibility. these small services are then composed together to make a cohesive system. the small services are independently deployable and distributable. in the new “cloud” world, elasticity is the game.
so how does spring and spring-boot help in this new world? prior to spring-boot, springsource (now aquired by pivotal) had simply supplied the world with a lot of different tools. it had always been up to the development community to figure out how to best put these pieces together. now with spring-boot, pivotal has put together a project that helps guide the usage of spring’s tools. by scanning the libraries on the classpath and configuring sensible defaults, it is almost trivial to start a new project.
applications written with spring-boot can be packaged as traditional war files. these war files can be deployed to the old-style application servers. however, the heavy weight application servers are out of favor in microservice environments. therefore, spring-boot applications can be packaged as an executable jar file that includes a server (either tomcat or jetty). the application can be ran as easily as typing
java -jar application.jar
that would be enough to get started. however, we will take it a step further and wrap the jar into a docker container. with docker, we are seeing the return of the “write once, run anywhere” saying that java had promised. as long as our deployment server has a recent linux kernel, we should be able to run our container. additionally, docker containers can be spun up and down as needed. again, with deployments to the cloud, this elasticity is huge.
this article is part one in a series that will introduce microservices. in this series i intend to cover:
- building/linking docker containers
- securing the rest endpoints with oauth
- separating the oauth authorization server from the resource server (critical in a microservice environment)
- exposing endpoints via rabbitmq
if there is something else that you would like to see covered in this series, please leave me a message in the comments. i will try to include all of the questions or suggestions.
Opinions expressed by DZone contributors are their own.