How to receive all the prefetch rabbitmq messages using spring framework?

爱⌒轻易说出口 提交于 2019-12-12 05:49:47

问题


I am learning to how use SimpleMessageListenerContainer to receive rabbitmq messages. My listener container has prefetchCount = 1000. However my listener worker implements the MessageListener interface which only receive one message at a time. Is there an interface to receive a list of messages? If there is not, how can I do to receive a list of messages? I don't want to process one message at a time but rather a list of them so I can do batch insert/update. I also want to acknowledge once for all of the messages that were delivered to me.

Thanks,

Sean Nguyen


回答1:


There is no such API; even the low-level rabbit client consumer delivers each prefetched message one at a time (via handleDelivery).

You will have to accumulate them into a list yourself.

Use the txSize property (set it the same as prefetch) to send a single ack after 1000 deliveries.



来源:https://stackoverflow.com/questions/27896778/how-to-receive-all-the-prefetch-rabbitmq-messages-using-spring-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!