Announcement Announcement Module
Collapse
No announcement yet.
MessageListener questions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MessageListener questions

    Hello.
    I have class, which implements MessageListener and DefaultMessageListenerContainer.
    I wanted to ask how the listener works.
    1. When triggered the onMessage method? Before when a message enters the queue or after?
    2. This method assyn or sync?
    3. If I have 2 or more listeners for one queue - which of these is invoked first?
    4. If one listener delete message from queue, others listeners not invoked?

  • #2
    I suggest you read the JMS specification to understand the basic concepts, and the Spring JMS Documentation.

    Simple answers...

    1. When a message is sent to the consumer from the broker (after the sender has sent the message - and committed a transaction if any).
    2. Not clear what you mean; each message is handled on a separate thread (the number of threads is managed by the container concurrency attributes).
    3. For a queue, only one consumer will ever get a message (topics are different - they are publish/subscribe and more than one consumer will get the message). The order in which consumers receive a message from a topic is indeterminate. Consumers only receive messages from topics if they are subscribed when the message arrives (unless they have a durable subscription - which is not the default).
    4. A message from a queue is only delivered to one and only one consumer. Consumers (listeners) do not "delete" messages, they consume them

    Comment

    Working...
    X