DMLC message consumption and acknowledgement

爷,独闯天下 提交于 2020-01-06 14:56:29

问题


This is a follow up question for Difference between AUTO_ACKNOWLEDGEMENT mode with and without Spring JMS.

I am using DMLC and my concurrent consumers count is 1. The prefetch limit is > 1. I received a message and it is acknowledged before listener is executed. So, while the listener is executing, broker has more messages and it sends it to consumer as per prefetch settings. Since the listener is still executing, how will the consumption and acknowledgement works for subsequent messages?

Will the receive() be called for all new messages and will they be acknowledged and wait for listener execution to complete? [If this is the case then I am confused why I am getting unacknowledgedmessagecount in consumer stats] OR The receive() will be called but next message will not be acknowledged until the previous listener has completed its execution? [this could potentially explain the unacknowledged messages if my listener execution is blocked due to some other reason] OR Something else happens under the hood.

Can someone please explain this? It will help me a lot.

Thanks and Cheers!


回答1:


No. receive() is called to get the first message; it is acknowledged when receive returns; the container thread then invokes the listener. (You have to use transactions with the DMLC if you want to roll back a failed delivery - if your listener throws an exception).

Any prefetched messages are delivered by the broker to the client library, but they will not be seen by Spring until your listener exits (onMessage()) after processing the previous message. i.e. receive() is called on the same thread as the MessageListener.

Prefetch is good in that the next message will be immediately available for the next receive(), but the downside is, if you have multiple consumer threads and a listener can sometimes take a long time to process a message, prefetched messages can sit in his queue while other threads are idle.



来源:https://stackoverflow.com/questions/28471833/dmlc-message-consumption-and-acknowledgement

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