Javatpoint Logo
Javatpoint Logo

Connecting Microservices to Zipkin

In this section, we will connect microservices to put their trace messages on the RabbitMQ. Once we place the messages on the RabbitMQ, it will be picked up by the Zipkin server.

Let’s connect the currency-conversion-service, currency-exchange-service, and the netflix-zuul-api-gateway-server to the RabbitMQ server.

Step 1: Open the pom.xml file of currency-conversion-service, currency-exchange-service, and the netflix-zuul-api-gateway-server and add the following dependencies:

We want to create a message in the format that it excepts. We need to add Zipkin dependency.

We will send the message to Zipkin that uses amqp message protocol. So we need to add the amqp dependency. Adding the dependency of amqp, we get the connection of RabbitMQ into currency-conversion-service, currency-exchange-service, and the netflix-zuul-api-gateway-server.

Now, we will try to run all the services together.

Using Zipkin UI Dashboard to trace the request

In this step, we will fire a request. But before firing a request, make sure that the five services are running correctly. We must run these five services in the following order. Otherwise, we get errors or incorrect responses.

Step 1: Run the following services in the same order as we have listed.

  • ZipkinDistributedTracingServerApplication (run from the Command Prompt)
  • (on port 8000)
  • (on port 8100)

Remember: Make sure that all the five applications are running correctly.

Step 2: Invoke the request http://localhost:8100/currency-converter-feign/from/EUR/to/INR/quantity/100. It returns the response properly.

But we are interested to know what is happening in the background.

Step 3: Open the Zipkin UI. It shows all the three services that we have connected to Zipkin.

Connecting Microservices to Zipkin

Step 4: Select any one service from the dropdown list and click on the Find Traces button. We have selected a currency-conversion-service. It shows the list of different execution of currency-conversion-service.

Connecting Microservices to Zipkin

Step 5: Select any one of them. It shows the entire trace of a service.

Connecting Microservices to Zipkin

In the above figure, when we invoke the currency-converter-feign, the request first goes to the API Gateway, and the API Gateway sends the request to the currency-exchange-service.

We can also see the detail of the services. In the following image, we have shown the details of the currency-exchange-service.

Connecting Microservices to Zipkin

The most important challenge in microservices is to bring visibility (what is happening in the background). Hence, the Zipkin server enables the visibility of the services.

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA