Search code examples
jmsspring-jmsjms-topic

topic subscriber behaviour during multiple messages on a topic for long running process


I have a topic and corresponding subscriber in the form of Spring DMLC. My questions is related to the following scenario :

A message is published on a topic and the subscriber starts processing the message. If another message arrives on this topic while the previous message is being processed, will the new message get lost assuming that subscriber is busy or this message will be processed after the previous message is processed.

If the answer is that the second message will be processed after the first message, then the follow up question is whether this behaviour is being handled by the broker or is the subscriber handling this.


Solution

  • The next message won't be lost unless the client unsubscribes (or dies) - you can make the subscription durable which means the message won't be lost even in that case.

    This (message handling) is under the control of the broker, not the client; whether a subscription is durable or not is up to the client.

    Some brokers offer a prefetch feature, in which case the message might be sent to the client while it's still processing the current one, but it still won't be lost if the client dies because the message is removed only after it is acknowledged.