Spring Boot Microservices With Docker (part one)

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:

  • Hosting a private repository
  • 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.

comments powered by Disqus