Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Getting Started With Microservices: An Example Application

DZone's Guide to

Getting Started With Microservices: An Example Application

Learn how to achieve scalability, high availability, and resilience by creating a microservice architecture in an application with the Vaadin framework.

· Microservices Zone ·
Free Resource

Containerized Microservices require new monitoring. See why a new APM approach is needed to even see containerized applications.

In my previous article about Microservices and User Interfaces, I discussed strategies for developing Vaadin-based applications in microservices architectures. In this article, I’ll show you an example application developed with a microservices architecture using Spring Boot and Vaadin Framework. The following is a screenshot of the application:

Image title

The left side is a completely separate and independent Vaadin application. The same is true for the right side of the page.

Downloading and Running the Application

Download the code from GitHub or from the command line with Git:

git clone https://github.com/alejandro-du/vaadin-microservices-demo.git

Compile the project using Maven:

cd vaadin-microservices-demo
mvn package

Start the discovery server:

cd vaadin-microservices/discovery-server
java -jar target/discovery-server-0.0.1-SNAPSHOT.jar

Start the configuration server:

cd vaadin-microservices/config-server
java -jar target/config-server-0.0.1-SNAPSHOT.jar

Run the microservices serving the actual functionality of the application:

cd vaadin-microservices/biz-application
java -Dserver.port=9601 -jar target/biz-application-0.0.1-SNAPSHOT.jar

cd vaadin-microservices/admin-application
java -Dserver.port=9401 -jar target/admin-application-0.0.1-SNAPSHOT.jar

cd vaadin-microservices/news-application
java -Dserver.port=9201 -jar target/news-application-0.0.1-SNAPSHOT.jar

cd vaadin-microservices/website-application
java -Dserver.port=9001 -jar target/website-application-0.0.1-SNAPSHOT.jar

And finally, start the proxy server:

cd vaadin-microservices-demo/proxy-server
java -jar target/proxy-server-0.0.1-SNAPSHOT.jar

Now you can request the proxy server at http://localhost:8080 and start using the application. Keep in mind that for simplicity, this demo doesn’t use any event bus communication and push features to update the tweets shown on the left. You have to reload the page to see the new data after using the CRUD web interface on the left of the page.

Scalability, High Availability, and Resilience

In order to scale parts of the system, you can simply start additional instances. For example, you can run more instances of  the admin-application (the one shown on the left side in the browser):

cd vaadin-microservices-demo/admin-application
java -Dserver.port=9401 -jar target/admin-application-0.0.1-SNAPSHOT.jar

Try stopping all instances of the biz-application and see what happens in the browser. The web applications should show error messages, when appropriate, without blocking the use of other parts of them. The news-application (the one on the right side in the browser) shows a predefined set of companies when the biz-application is not up.

You can find a more detailed tutorial at vaadin.com.

Automatically manage containers and microservices with better control and performance using Instana APM. Try it for yourself today.

Topics:
microservices ,java ,spring ,vaadin ,tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}