【问题标题】:Using feign client for interal and external service communication使用feign客户端进行内外部服务通信
【发布时间】:2020-05-15 21:38:34
【问题描述】:

我们有多个服务,我们使用 feign 客户端进行通信(所有都是 Spring Boot 应用程序)。但是,我有一个场景,我们必须与外部服务进行通信。如果我通过url,它会起作用,但我想知道这是否是正确的做法。

 @FeignClient(
    name = "foo",
    url = "${some.url.from.env}",
    configuration = FeignConfiguration.class) 

public interface FooClient {
  @PostMapping("search/{searchQuery}")
  ResponseEntity<JsonNode> getData(
      @RequestBody POJO someObject);

感谢任何建议。

PS:对不起,如果我没有遵循 stackoverflow 规则(我的第一篇文章)。

【问题讨论】:

    标签: java spring spring-boot service-discovery feign


    【解决方案1】:

    完全没问题。这个库 (https://github.com/OpenFeign/feign) 的主要思想是帮助您以更具声明性的方式更轻松地编写任何 HTTP 客户端。

    后来,https://github.com/spring-cloud/spring-cloud-openfeign 将其与 Spring Cloud 集成,“包装器”的想法之一是管理使用 Spring Cloud 构建的微服务之间的请求。但这不是它的唯一用途。

    【讨论】:

      猜你喜欢
      • 2011-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-11
      相关资源
      最近更新 更多