我在使用java代码在rabbitMQ中发布一些数据时遇到异常。
当我们试图在兔子中发布过多的并发数据时,如果负载很高。
跟踪正在打印。
java.lang.Error: Maximum permit count exceeded
at java.util.concurrent.Semaphore$Sync.tryReleaseShared(Semaphore.java:192)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.releaseShared(AbstractQueuedSynchronizer.java:1341)
at java.util.concurrent.Semaphore.release(Semaphore.java:426)
at com.rabbitmq.client.impl.WorkPool.increaseUnlimited(WorkPool.java:158)
at com.rabbitmq.client.impl.WorkPool.access$200(WorkPool.java:70)
at com.rabbitmq.client.impl.WorkPool$WorkQueue.setUnlimited(WorkPool.java:122)
at com.rabbitmq.client.impl.WorkPool.unlimit(WorkPool.java:184)
at com.rabbitmq.client.impl.ConsumerWorkService.unlimit(ConsumerWorkService.java:68)
at com.rabbitmq.client.impl.ConsumerDispatcher.setUnlimited(ConsumerDispatcher.java:66)
at com.rabbitmq.client.impl.ChannelN.enqueueRpc(ChannelN.java:1193)
at com.rabbitmq.client.impl.AMQChannel.quiescingRpc(AMQChannel.java:232)
at com.rabbitmq.client.impl.AMQChannel.rpc(AMQChannel.java:224)
at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:209)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:118)
at com.rabbitmq.client.impl.ChannelN.queueDeclare(ChannelN.java:833)
at com.rabbitmq.client.impl.ChannelN.queueDeclare(ChannelN.java:61)
at ProcessRawReport.feedToRabbit(ProcessRawReport.java:89)
at ProcessRawReport.doGet(ProcessRawReport.java:78)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
答案 0 :(得分:1)
我打赌你有3.4.2版本的RabbitMQ amqp-client或接近它的东西。从只读取WorkPool / WorkQueue类的代码看起来,它们可以比获取它更容易地释放信号量。许可证的数量不断增加。一旦达到Integer.MAX_VALUE,您将获得与您提供的异常相同的异常。在闲置系统上可能需要花费大量时间,但随着负载的增加,时间会缩短。对于我们的RabbitMQ服务器,它需要大约6周的时间才会崩溃。
在客户端的较新版本中,他们刚刚完全删除了信号量逻辑,因此我建议您尝试将客户端库升级到3.5.x或3.6.x。