我在我的应用程序中使用Eureka,Zuul,Hystrix和复合服务。 RabbitMq我用于消息队列。在运行测试用例时,我遇到了以下异常。我的测试运行正常,但得到如下例外:
11:38:16.597 [task-scheduler-4] ERROR o.s.c.n.h.amqp.HystrixStreamTask - Error adding metrics to queue
java.lang.IllegalStateException: Queue full
at java.util.AbstractQueue.add(Unknown Source) ~[na:1.8.0_66]
at org.springframework.cloud.netflix.hystrix.amqp.HystrixStreamTask.gatherMetrics(H ystrixStreamTask.java:289) ~[spring-cloud-netflix-hystrix-amqp- 1.0.0.RELEASE.jar:1.0.0.RELEASE]
at sun.reflect.GeneratedMethodAccessor62.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~ [na:1.8.0_66]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_66]
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMeth odRunnable.java:65) [spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [na:1.8.0_66]
at java.util.concurrent.FutureTask.runAndReset(Unknown Source) [na:1.8.0_66]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301( Unknown Source) [na:1.8.0_66]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [na:1.8.0_66]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_66]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_66]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_66]
答案 0 :(得分:0)
您的队列似乎已满。使用x-max-length或x-max-length-bytes属性增加队列长度。
可以找到更多信息here
答案 1 :(得分:0)
将Spring Cloud从Angel.SR4
升级到Brixton.M4
后,我遇到了类似的问题。用
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
似乎已经解决了这个问题。根据您的依赖关系,这可能会有所帮助!
更全面地了解我的代表:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-hystrix-amqp</artifactId>
<version>${spring.cloud.netflix.hystrix.amqp.version}</version>
<exclusions>
<exclusion>
<groupId>com.goldmansachs</groupId>
<artifactId>gs-collections-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.goldmansachs</groupId>
<artifactId>gs-collections</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>