DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Component Tests for Spring Cloud Microservices
  • Spring Boot - How To Use Native SQL Queries | Restful Web Services
  • Spring Boot: Testing Service Layer Code with JUnit 5 and Mockito, RESTful Web Services
  • Distributed Tracing System (Spring Cloud Sleuth + OpenZipkin)

Trending

  • Introduction to Retrieval Augmented Generation (RAG)
  • Using the Spring @RequestMapping Annotation
  • S3 Vectors: How to Build a RAG Without a Vector Database
  • LLM Integration in Enterprise Applications: A Practical Guide
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Building Microservices With[out] Spring Boot

Building Microservices With[out] Spring Boot

Spring Boot has made building microservices almost effortless, but you can use other tools to achieve the same result. Read on to learn how.

By 
Vinod Pahuja user avatar
Vinod Pahuja
·
Jun. 01, 18 · Tutorial
Likes (11)
Comment
Save
Tweet
Share
27.4K Views

Join the DZone community and get the full member experience.

Join For Free

Microservices...microservices everywhere.

Everyone is talking about microservices and tools and framework to build them. One common name you may have heard of is Spring Boot. It has made creating microservices so quick and easy that even a novice developer can build one in few minutes. 

Apart from development and monitoring, a microservice consists of the following phases:

  • Packaging
  • Deployment
  • Launcher

Let's first discuss all these in details with regards to Spring Boot.

Spring Boot

Spring Boot provides out-of-the-box support for all these phases, with dedicated components in the form of plugins and modules. 

Packaging - It provides its own Maven support to package the code and all dependencies as an Uber jar, including the container itself. For this, you need to add the following build plugin and a simple repackage goal that repackages the binary built during the normal Maven package phase.

Deployment - It comes with a different type of web container to support the embedded deployment of web resources like servlets/JSP. On top of that, it provides a Jersey container that can deploy RESTful resources.

Launcher - Spring Boot has made launching an application as easy as running the Hello World program. Only one line of code triggers the dependency management, package scan, and container initialization.

Reference Code: microservice-starter-springboot

After looking into all these aspects, these artefacts could be made using different tools and frameworks. Let discuss eachweb server and platform. 

Tomcat

Tomcat is generally used as web container for deploying web applications, but it can also be used as an embedded container for running packaged microservices. For this, it requires the things below to make a contained microservice.

Packaging - Unlike Spring Boot, it does not provide an out-of-the-box solution for packaging your microservice, but you can use a Maven standard plugin like assemble and shade to build an Uber jar that contains all the dependencies and supports main class manifests.

Deployment - All the Tomcat runtime modules can be provided with a single dependency that can deploy and run the Jersey container.

Launcher - Tomcat allows you to configure your endpoint and container programmatically, and you can start and stop the instance within your control.

Reference Code: microservice-starter-tomcat

Jetty

Jetty is a perfect fit for deploying and running microservices as it mostly uses an embedded container for running web applications. It also follows the same pattern as Tomcat to run microservices.

Packaging - It can utilize Maven standard plugins to package your code and dependencies in a single Uber jar.

Deployment - Jetty provide a servlet container that can be topped up by a Jersey container to serve web services.

Launcher - Like Tomcat, it provides a similar programmatic API to deploy Jersey containers and REST endpoints.

Reference Code: microservice-starter-jetty

Grizzly

Grizzly is a less popular web container, but it powers the most standard application server for the JEE community. Yes, it's the engine behind the Glassfish server. It does provide out-of-the-box features for building microservices.

Packaging - We can use a Maven standard plugin like assembly and shade for packaging the web service and its dependencies.

Deployment - Unlike Tomcat and Jetty, it provides built-in support for deploying web services built using Jersey and provides standard container-based Grizzly HTTP services.

Launcher - Like Spring Boot, it provides a very abstract API for configuring REST services and running the container itself within a single line of code.

Reference Code: microservice-starter-grizzly

Netty

Netty is a well-known async and event-driven client/server framework that supports the majority of protocols like FTP, SMTP, and HTTP and provides low-level programming for UDP and TCP applications. On top of that, Glassfish provides a special Jersey container that uses non-blocking IO and HTTP services. It can be used as a web service container in a similar fashion to Grizzly.

Packaging - We can use a Maven standard plugin like assembly and shade for packaging the web service and its dependencies.

Deployment - Like Grizzly, it provides out-of-the-box support for deploying web services built using Jersey and provides a standard container based on Netty HTTP services.

Launcher - Like Grizzly, it provides a very abstract API for configuring REST services and running the container.

Reference Code: microservice-starter-netty

Undertow

Undertow is a web server that powers the popular JBoss AS and is able to run as an embedded container. It provides granular HTTP and non-blocking IO services. On top of that, it provides Servlet and Web Socket implementations. It can be used for building microservices in a similar fashion.

Packaging - We can use a Maven standard plugin like assembly and shade for packaging the web service and its dependencies.

Deployment - Undertow provides an HTTP Servlet container that can be used with a Jersey Servlet container.

Launcher - It also provides a programmatic API to deploy the Jersey container and REST endpoints.

Reference Code: microservice-starter-undertow

Conclusion

Now we have seen that Spring Boot is good for microservices, but you can build one with basic tool and frameworks. Also starting up is not too difficult as shown in these starter code references.

Spring Framework microservice Spring Boot Web Service Container

Opinions expressed by DZone contributors are their own.

Related

  • Component Tests for Spring Cloud Microservices
  • Spring Boot - How To Use Native SQL Queries | Restful Web Services
  • Spring Boot: Testing Service Layer Code with JUnit 5 and Mockito, RESTful Web Services
  • Distributed Tracing System (Spring Cloud Sleuth + OpenZipkin)

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook