我们可以使用AWS API Gateway使用Feign客户端吗?

发布于 2025-02-13 04:30:31 字数 115 浏览 1 评论 0原文

我们使用AWS API网关管理了几个微服务,这也充当负载平衡器。我们尚未集成弹簧云和尤里卡服务来执行负载平衡并调用外部服务调用。

仅仅因为不编写单位测试用例而替换reteptemplate是有意义的吗?

We have a couple of microservices managed using AWS API Gateway which also acts as a load balancer. We have not integrated spring cloud and eureka services to perform load balancing and invoke external service calls.

Does it make sense to replace RestTemplate with feign-client only for not writing unit test cases?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清旖 2025-02-20 04:30:31

不确定这与单元测试有何关系,但是您可以使用Spring Cloud OpenFeign替换RESTTEMPLATE,以获得更精简,更可读的API。它还可以在引擎盖下为您处理客户端的负载平衡。但是,您可能希望等到Spring 6版本,然后切换到新的 Spring Interface Client

Not sure how this is related to unit tests, but you can replace RestTemplate with Spring Cloud OpenFeign for a leaner, more readable API. It may also handle client-side load-balancing for you under the hood. However, you might wish to wait till Spring 6 release and switch to using the new Spring interface client instead.

橪书 2025-02-20 04:30:31
  • 我们可以不使用Eureka服务器和配置客户端使用Feign Client。假装客户端位于其余模板的顶部。

  • 因此,在两个微服务端客户端之间有更好的互通功能正常。

  • 您需要做的就是为feign Client @feignclient提供其他参数以及名称param

  • 端口需要是固定端口,并且不能由Spring Boot随机提供。因此用户服务器端口

@feignclient(name =“用户profile-service”,
url =“ $ {client.user-profile-service.baseurl}”)

application.yml

client:
  skill-service:
    baseurl: http://localhost:3202
  • We can use feign client without using the eureka server and config client. Feign client sits on top of the rest template.

  • So for better intercommunication between two microservices feign client works fine.

  • All you need to do is to supply additional parameter for url to the feign client @FeignClient along with name param

  • The port needs to be a fixed port and cannot be randomized provided by spring boot. So user server port

@FeignClient(name = "user-profile-service",
url="${client.user-profile-service.baseurl}")

application.yml

client:
  skill-service:
    baseurl: http://localhost:3202
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文