richard
richard

Reputation: 2053

spring boot microservice framework how to call another microservice from one microservice

I am trying to build a new application with spring boot microservice framework. I have tried some demo. The existing demo is too simple, doesn't introduce how to call another service from one service. Should still going through http, or should going through RPC? If going RPC, which RPC framework support?

Upvotes: 0

Views: 6178

Answers (3)

Anil Nivargi
Anil Nivargi

Reputation: 1717

Use RestTemplate or FeignClient for Synchronous Spring based Rest api's. Use any message tools for Asynchronous calls like Kafka, ActiveMQ or RabbitMQ.

Upvotes: 0

bart.s
bart.s

Reputation: 688

The way of integrating among services depends on numerous factors, like synchronicity/asynchronicity, load that will be generated, etc. The most popular (I guess) way of integration is REST-based one. Because you tagged your question with spring I would recommend using declarative REST client - Feign that is very well described here. You can use message brokers as well, which are also very well abstracted by Spring Cloud Stream - you can read more here. I think that more in depth discussion should be based on your needs.

Upvotes: 2

Amit
Amit

Reputation: 32376

If another micro-services are exposing the REST API , then you can simple use jersey client

or httpclient to call them.

Upvotes: 1

Related Questions