wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Clarification regarding JMS msg Consumer vs Msg Listener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Clarification regarding JMS msg Consumer vs Msg Listener" Watch "Clarification regarding JMS msg Consumer vs Msg Listener" New topic

Clarification regarding JMS msg Consumer vs Msg Listener

hildich kilal
Ranch Hand

Joined: Aug 25, 2008
Posts: 44
I am confused between how a message consumer differs from message listener.
So I understand messageListener is for asynchronous messaging. We create a message consumer and then
set messageListener on it.

So usually when i create separate MessageConsumer and explicitely set a message Listener to them then it means
that there are many consumers but one Listener only listening on queue. But how does it help? Because the logic
to handle a message is still at one place? How will creating multiple consumers with same listener helps?

If I have a class which implements Messagelistener and then creates a messageConsumer inside it and
uses setMessagListener(this) to register listener . some thing like following

Now if I create multilpe instances of this class and call start() on them does that mean that now there are
multiple listeners listening on the queue?

H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 395
Hope this will anwer your questions.

Point-to-Point Messaging Domain
Message Consumption

JMS Message Consumers
JMS Message Listeners
ntumba lobo
Ranch Hand

Joined: Oct 21, 2008
Posts: 180
You can see the JMS consumer as the generic component for message consumption, Message listener is a specialized consumer.
You can consume messages in two different ways
a) asynchronously : you use a Message Listener that you set up on your consumer object
b) synchronously : you call receive() on the consumer object

wood burning stoves
subject: Clarification regarding JMS msg Consumer vs Msg Listener
Similar Threads
JMS (Transaction ?) problemen on Weblogic 10.3
My AsynchronousConsumer Won't Listen!
Need help with JMS+ Spring + ActiveMQ
JMS Consumer ends even after implementing MessageListener interface.
JMS Consumer not receiving any messages.