RabbitMQ basic.get and acknowledgement

前端 未结 2 688
情深已故
情深已故 2021-01-17 01:25

I\'m invoking:

GetResponse response = channel.basicGet(\"some.queue\", false); // no auto-ack
....
channel.basicAck(deliveryTag, ...);

Howe

2条回答
  •  伪装坚强ぢ
    2021-01-17 02:00

    When doing ack immediately after the get it works fine. However, in my case, they were separated by a request. And spring's template closes the channel and connection on each execution. So there are three options:

    • keep one channel and connection open throughout the whole lifetime of the application
    • have some kind of conversation-scope (or worst-case: use the session) to store the same channel and reuse it.
    • use one channel per request, acknowledge receipt immediately, and store the messages in memory.

    In the former two cases you can't do it with spring's RabbitTemplate

提交回复
热议问题