RabbitMq connection timeout exception

Using spring amqp (rabbitmq):

My consumer takes quite a lot of time to process message sometimes my business logic takes more than 2 hours but then after the processing when I try to acknowledge the rabbitmq for "basic ack" it throws connection timeout exception.

What should I do ? Should I make connection live forever or use heartbeats ?


If your logic definitely is based on MANUAL ack, you indeed don't have choice unless make your connections long living. Heartbeat should be there by default anyway.

Otherwise consider the solution with the AUTO ack and in case of errors afterward downstream just send messages back to the queue for retying in the future.


Consider an alternative option with ack-ing right after your long-lasting business operation starts and later informing about its status: either failure or success, in case if you have any dependent actors.

As Artem & Gary suggest that it's quite an anti-pattern to hold messages for a long time, you may want to make the process really async -- your service consumed a message and started doing some stuff: good then, let's acknowledge that. And in case if you need to repeat on failure, just make a separate message once failure appears, so another consumer would take it and process it.

链接地址: http://www.djcxy.com/p/34110.html

上一篇: AMQP 1.0实施在哪里? 等待是否有意义?

下一篇: RabbitMq连接超时异常