mq java客户端,RabbitMQ Java客户端停止使用消息

My application consumes some messages from RabbitMQ and processes them.

I have about 10 queues and each queue has up to ten consumers (threads).

I have a prefetch of 5. I'm running my setup in Heroku using the CloudAMQP plugin (RabbitMQ as a service).

I'm running with the default heartbeat and connection timeout settings (60 seconds).

My java application is a spring boot application using the spring-rabbit library.

Versions:

RabbitMQ 3.5.3

Erlang 17.5.3

Java 1.8

Spring boot 1.3.2.RELEASE

Spring rabbit 1.5.3.RELEASE

The problem is that for the consumers of one particular queue stop consuming messages after some time. When I restart my java application everything works fine. The other queues are being consumed normally though. No errors on the application's side. On the log stream of rabbit's side I see some entries like

= REPORT==== 2016-08-02 15:53:32 UTC ===

closing AMQP connection (SOMETHING_ELSE -> SOMETHING_ELSE_ELSE):

{heartbeat_timeout,running}

I can't reproduce locally or in a testing environment in Heroku.

Update

The code below can be found in AMQConnection.class

int heartbeat = negotiatedMaxValue(this.requestedHeartbeat,

connTune.getHeartbeat());

private static int negotiatedMaxValue(int clientValue, int serverValue) {

return (clientValue == 0 || serverValue == 0) ?

Math.max(clientValue, serverValue) :

Math.min(clientValue, serverValue);

}

I can't increase the value of the heartbeat above 60 seconds (which is what I'm getting from the server).

解决方案

Unfortunately, this seems like a networking issue. This could be due to a few things:

The CloudAMQP service is having some issues and is killing your connection (not likely since your other consumers are working OK).

Your CloudAMQP plan doesn't allow for as many concurrent connections as you want. Have you checked to ensure you are on a sufficiently high enough plan to support all of your consumers? https://elements.heroku.com/addons/cloudamqp

Your Heroku dyno with the consumer in question is restarting, which is dropping your connection. Heroku dynos periodically restart. If your dynos can't gracefully restart, you might want to investigate why.

One of your Heroku dynos is having network issues (in which case it will likely be restarted on its own without your intervention).

One way to force all of your dynos to restart is to run $ heroku ps:restart. This will force Heroku to restart your dynos, which frequently means moving them to a new EC2 host. This may help if it is a one off issue.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值