Reputation: 2896
I would like to know what happens if MessageListenerContainer, pointing to a topic, recieves 2 (or more) messages at the same time.
For example, 2 users of the app triggers a publish at the same time, hence 2 jmstemplate calls sending 2 different messages to the same topic.
How will the container handle this?
Upvotes: 1
Views: 4418
Reputation: 32066
The concurrency setting controls how many listeners consume messages concurrently. You should not use more than 1 consumer for topics, otherwise, the message may be consumed twice on the same node.
<jms:listener-container
container-type="default"
connection-factory="connectionFactory"
acknowledge="auto"
concurrency="1"
cache="consumer">
<jms:listener destination="TEST.FOO"
ref="simpleMessageListener"
method="onMessage" />
</jms:listener-container>
See this too... https://stackoverflow.com/a/5808803/791406
Spring Docs... http://static.springsource.org/spring/docs/3.0.5.RELEASE/api/org/springframework/jms/listener/DefaultMessageListenerContainer.html
Upvotes: 1