Spring Boot - how to communicate between microservices?

后端 未结 6 2071
逝去的感伤
逝去的感伤 2021-02-07 15:59

I\'m currently working on a Spring Boot microservices project. I have created services and each service is running separately. With this, I need some services to communicate wit

6条回答
  •  -上瘾入骨i
    2021-02-07 16:45

    the post seems old but I will try to share my experiences with the new developers who searches solutions for the same problem.

    You will need these libraries: Zuul Gateway, Eureka Discovery Server, Eureka Discovery Client, Rest Template (if you develop REST API).

    Gateway can manage all the routing for spring boot microservice applications. Using only annotations and application.properties you can set up the whole server. You do NOT need to write single line of Java code.

    Discovery server listens evens when new microservice is started or stopped. It registers all microservices which are annotated with @EnableEurekaClient.

    Rest Template is a mature rest client library which is very much flexible in terms of custom http request and http response configurations. For instance, you can use client http interceptors configurations to intercept the http request and responses to add more data, or log info etc.

    I have open-sourced microservice application on my GitHub page. Free to distribute, fork, clone, commercialize.. Free from desire :-)

    All the best..

提交回复
热议问题