
Spring Cloud
北漂编程小王子
程序猿的工作日记
展开
-
Spring Cloud Feign 请求 动态URL 动态的Token
项目进行遇到一个问题,就是我们每增加一个服务调用的时候,基本都是增加一个Feign接口,这样可能会面临尴尬的问题,不同的URL调用时,会copy一堆的Feign接口,这显然不是我们最佳的方案,如果能使用一个Feign接口,在不同逻辑下动态请求不同的URL,同时不同的URL携带不同的Token信息…@FeignClient(name = "TetsFeignClient")public interface TestFeignClient { @RequestLine("GET /test/heal原创 2021-10-12 13:03:52 · 1407 阅读 · 0 评论 -
Spring Cloud Feign 使用示例
现在本地项目需要调用其他项目组的服务接口,两者服务之间通过TOKEN验证,实现接口互通。在调用的Controller中或者Service中直接注入TestApiClient 即可。@FeignClient(value = "TetsApiClient", url = "${api.test.homeUrl}/api/v1",configuration = FeignConfig.class)public interface TestApiClient { @PostMapping("/list原创 2021-10-12 11:52:41 · 396 阅读 · 0 评论 -
Spring 事务提交之后再执行操作
Spring代码实现:package xxxx.components;import lombok.extern.slf4j.Slf4j;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.stereotype.Component;import org.springframework.transaction.support.TransactionSynchronizationAdapt原创 2021-05-14 15:15:51 · 1807 阅读 · 0 评论 -
com.netflix.client.ClientException: Load balancer does not have available server for client
一、问题描述报错信息如下{ "success": false, "message": "com.netflix.client.ClientException: Load balancer does not have available server for client: rm-provider", "code": "InternalServerError", "data": null, "timestamp": 1620886655662}二、错误原因在SpringBoot原创 2021-05-13 14:39:04 · 1512 阅读 · 0 评论 -
Spring Cloud 使用FeignClient 调用外部API(包含超时和重试机制)
由于项目需要,开发的系统需要调用外部系统API接口,所在项目使用的是Spring Cloud 分布式架构,利用自身提供的FeignClient作为内部和外部服务调用的工具,需要配置超时重试机制,用来满足业务以及系统上的需要。我们的需求是当调用API发生网络错误或者超时异常时,需要连续调用2次接口,第一次间隔5分钟,第二次调用间隔10分钟,系统最大超时时间是150000毫秒。项目代码如下:首先...原创 2018-12-28 16:42:37 · 10471 阅读 · 0 评论 -
Spring Cloud 微服务架构图
Spring Cloud 微服务总体架构图上面图中技术名词理解:1、Sleuth-链路跟踪为服务之间调用提供链路追踪。通过Sleuth可以很清楚的了解到一个服务请求经过了哪些服务,每个服务处理花费了多长。从而让我们可以很方便的理清各微服务间的调用关系。2、断路器(Hystrix)在微服务架构中,根据业务来拆分成一个个的服务,服务与服务之间可以相互调...原创 2018-08-15 11:32:43 · 77365 阅读 · 8 评论