获取eureka的注册服务的实例列表

原创 2022-07-05 16:54 阅读(1075)次
如果获取eureka中服务对应的实例列表? 代码如下: ```java @Autowired private SpringClientFactory factory; ``` ```java ILoadBalancer lb = factory.getLoadBalancer("xxxx"); //指定服务名 List allServers = lb.getAllServers(); List upServers = lb.getReachableServers(); ``` 运行结果: ...

LOG_PATH_IS_UNDEFINED/info.log (No such file or directory)

原创 2021-10-18 17:42 阅读(1658)次
本文介绍解决java.io.FileNotFoundException: LOG_PATH_IS_UNDEFINED错误。 微服务在本地部署没有问题,部署在rancher中却报如下错误: ``` 2021-10-18 17:10:47.886 ERROR [pip-data-lifecycle-management] [10.42.2.53:serverPort_IS_UNDEFINED] [main] o.s.boot.SpringApplication : Application run failed java.lang.IllegalStateException: Logba...

调用别人的接口或第三方接口怎么做熔断(二)

原创 2021-05-18 16:27 阅读(1210)次
上一篇文章《[调用别人的接口或第三方接口怎么做熔断](http://www.classinstance.cn/detail/152.html "调用别人的接口或第三方接口怎么做熔断")》我分享了自己在生产环境中遇到调用下游第三方服务异常几乎把自己服务拖跨的问题,以及分享了如何解决这个问题。 这篇主要分享如何用代码实现对第三方异常服务做熔断来保护自己的服务。 待续

调用别人的接口或第三方接口怎么做熔断

原创 2021-05-14 18:49 阅读(2486)次
在我们开发过程中总会遇到开发服务接口给别人调用,或者让别人的服务提供接口给你调用。别人的服务调用我们的服务接口的情况,我们为了保护自己的服务不被高并发或者说大量请求压垮,往往会做限流或者熔断。但是我们调用别人的服务接口需要做限流或熔断么? 我们举个例子: 我们系统有个场景就是要将产生的预警信息快速同步给下游第三方服务中,实时性要求比较高。预警信息是从kafka中消费的,每一条预警信息都要发给多个第三方服务。大致流程如下: ![](http://img.classinstance.cn/20210514/1620987481312.jpg) 图中一条预警信息从kafka拉取后...

feign报错java.lang.IllegalStateException: RequestParam.value() was empty on parameter 0

原创 2020-03-26 10:29 阅读(3822)次
修改了一下feign接口,原本可以的接口突然报错:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cn.com.datu.thirdpartapi.feign.OpodMetaOfProfileFeign': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: RequestParam.value() was empty...

spring cloud config取不到配置@Value报错: Could not resolve placeholder 'xxxx' in value

原创 2020-01-02 11:28 阅读(11422)次
我们项目是使用spring cloud config作为微服务配置管理,使用的是本地文件形式,今天我重新下载了一份配置,修改了配置服务的文件地址,然后config client的项目就启动不了了,一直报错:Could not resolve placeholder 'xxxx' in value "${xxxx}"开始以为是项目配置格式问题,后来想到应该是我改了config server的配置地址:spring: application: name: ms-config-server profiles: active: native c...

Caused by: java.net.BindException: Address already in use: connect

原创 2019-12-05 17:23 阅读(2513)次
在用jmeter测试seata性能时,并发到了200多,部分请求能正常访问,部分却报地址被占用Caused by: feign.RetryableException: Address already in use: connect executing POST http://mcu-stock/api/stockInfo/saveStockDetail看了下jmeter请求日志,jmeter自身也在报这个错误java.net.BindException: Address already in use: connect明显这个错误跟我们看到的tomcat端口被占用不一样我服务端feign错误日志...

dubbo项目consumer和provider的启动顺序问题

原创 2019-11-11 12:42 阅读(3211)次
dubbo项目服务调用端consumer默认需要服务提供端provider先启动才能启动,否则会报错: Failed to check the status of the service xxxx. No provider available for the service xxxx这是由于consumer端默认会检查项目里服务提供者是否可用,所以这要求dubbo项目之间要有启动顺序,这显然不符合我们日常开发与部署,谁知道微服务中谁调用谁呢,况且项目之间并不是单纯的服务提供者与调用者,可能会杂在一起,不过dubbo已经提供了关闭这个检查的配置它可以配置在@Reference注解上 @...

sprinb boot整合apache dubbo时报错 java.lang.NoClassDefFoundError: org/apache/curator/utils

原创 2019-11-11 12:14 阅读(4634)次
搭建spring boot + dubbo微服务时,有个服务工程一直报错:Caused by: java.lang.NoClassDefFoundError: org/apache/curator/utils/DefaultZookeeperFactory at org.apache.curator.framework.CuratorFrameworkFactory.<clinit>(CuratorFrameworkFactory.java:66) ~[curator-framework-4.0.1.jar:4.0.1] at org.apache.dubbo.remoti...

spring boot整合apache dubbo时报错ConfigFileApplicationListener.supportsSourceType(Ljava/lang/Class;)Z

原创 2019-11-10 23:24 阅读(5158)次
spring boot整合apache dubbo时报错:Exception in thread "main" java.lang.AbstractMethodError: org.springframework.boot.context.config.ConfigFileApplicationListener.supportsSourceType(Ljava/lang/Class;)Z at org.springframework.context.event.GenericApplicationListenerAdapter.supportsSourceType(Ge...

spring cloud gateway 获得响应body记录日志问题

原创 2019-10-30 11:07 阅读(2183)次
通常在spring cloud微服务架构中,需要在网关gateway中记录日志,比如需要记录响应的body,今天我也是一直遇到响应体记录不完整的问题,body被分段,对于响应报文大一点的请求中,在响应ServerHttpResponseDecorator包装中一次取得body只能取的一段。有问题的代码如下: ServerHttpResponse originalResponse = exchange.getResponse(); DataBufferFactory bufferFactory = originalResponse.bufferFactory(); Serve...

seata并发测试报错:get global lock fail, xid:192.168.64.1:18091:2025291279, lockKeys:stock_info:1

原创 2019-10-20 22:42 阅读(7128)次
我在做seata并发测试时报如下错误,并发只有3个,其中一个报获得全局锁失败:2019-10-20 22:07:21.548 INFO 22228 --- [nio-8092-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet' 2019-10-20 22:07:21.548 INFO 22228 --- [nio-8092-exec-2] o.s.web.servlet.DispatcherServlet : ...

feign报错:cannot retry due to redirection, in streaming mode

原创 2019-10-18 17:13 阅读(11383)次
feign调用报错:Caused by: feign.RetryableException: cannot retry due to redirection, in streaming mode executing POST http://G-PC-PERSON-CENTER/person/privilege/doSendOrderPayStatus at feign.FeignException.errorExecuting(FeignException.java:132) at feign.SynchronousMethodHandler.executeAndDecode(Sync...

feign接口类扫瞄找不到的问题,required a bean of type 'xx.xx.xxxFeignClient' that could not be found

原创 2019-09-24 17:40 阅读(2682)次
在搭建spring cloud微服务时经常会遇到如下错误:Description: Field orderInfoFeignClient in com.mcu.stock.service.StockService required a bean of type 'com.mcu.common.feign.order.OrderInfoFeignClient' that could not be found. The injection point has the following annotations: - @org.springframework.beans.factor...

修改seata server启动服务端口

原创 2019-09-24 09:46 阅读(8851)次
下载地址:https://github.com/seata/seata/releases里面都是linux、windows都同时可以用的绿色版安装包直接双击seata-server.bat就可以默认启动,默认端口为8091,如果想修改端口,也可以用配置项启动,参数如下:Options: --host, -h   The host to bind.   Default: 0.0.0.0 --port, -p   The port to listen.   Default: 8091 --storeMode, -m   log store mode...

spring cloud+feign+mybatis中使用seata0.9实现分布式事务

原创 2019-09-23 17:11 阅读(6320)次
seata前身叫fescar,是阿里开源的实现分布式事务中间件。官网地址:https://github.com/seata/seata中文文档:https://github.com/seata/seata/wiki/Home_Chinese原理就不说了,话不多说,直接分享代码:首先需要安装seata服务,下载地址:https://github.com/seata/seata/releases里面都是linux、windows都同时可以用的绿色版安装包1.启动seata服务默认以file形式注册,直接可以启动,启动端口默认为8091sh seata-server.sh -p 8091加上-p参数...

spring cloud集成分布式事务中间件seata报错 not support register type: null

原创 2019-09-23 11:50 阅读(8602)次
在启动seata中的RM端时报错:Caused by: io.seata.common.exception.NotSupportYetException: not support register type: null at io.seata.config.ConfigurationFactory.buildConfiguration(ConfigurationFactory.java:87) at io.seata.config.ConfigurationFactory.getInstance(ConfigurationFactory.java:71) at io.seata.s...

feign加入熔断器之后转发不了token等header信息

原创 2019-07-26 11:53 阅读(2238)次
feign加入hystrix熔断器之后转发不了token等header信息,我把熔断注释了,就可以转发。但这不是我想要的答案。转发代码如下:@Configuration public class FeignConfig implements RequestInterceptor { @Override public void apply(RequestTemplate requestTemplate) { ServletRequestAttributes attributes = (ServletRequestAttributes)RequestCont...

spring cloud中Feign调用诡异报错MethodNotAllowed: status 405 reading

原创 2019-07-24 13:14 阅读(8173)次
微服务中使用feign内部调用报错:Caused by: feign.FeignException$MethodNotAllowed: status 405 reading VisitorFeignClient#login(String) at feign.FeignException.errorStatus(FeignException.java:100) at feign.FeignException.errorStatus(FeignException.java:86) at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.jav...

spring cloud gatewayThe ‘Access-Control-Allow-Origin’ header contains multiple values

原创 2019-07-16 20:53 阅读(4715)次
在spring cloud gateway网关中加入了跨域支持,但是报了:The ‘Access-Control-Allow-Origin’ header contains multiple values “*, *”, but only one is allowed.错误显示设置了两次Access-Control-Allow-Origin:*,但我的代码我确定只设置了一次,怀疑是哪出了问题,找了一上午问题,百度到说是gateway的bug我的版本:spring cloud gateway:2.1.2spring cloud: Greenwich.SR2解决办法如下:设置跨域:imp...

spring cloud gateway报错Only one connection receive subscriber allowed

原创 2019-07-08 11:06 阅读(4484)次
spring cloud网关报错:reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalStateException: Only one connection receive subscriber allowed. Caused by: java.lang.IllegalStateException: Only one connection receive subscriber allowed. at reactor.ipc.netty.channel.FluxReceive.startRecei...

openfeign与gateway中的httpClient类声明冲突

原创 2019-07-06 12:27 阅读(2783)次
启动spring cloud中的网关,报错:***************************APPLICATION FAILED TO START***************************Description:The bean 'httpClient', defined in class path resource [org/springframework/cloud/openfeign/ribbon/HttpClientFeignLoadBalancedConfiguration$HttpClientFeignConfiguration.class], could not...