aspose file tools*
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
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
Author

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?

Thanks,
H Paul
Ranch Hand

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

http://java.sun.com/javaee/5/docs/tutorial/doc/bncdq.html
http://java.sun.com/javaee/5/docs/tutorial/doc/bncdx.html
Point-to-Point Messaging Domain
Message Consumption

http://java.sun.com/javaee/5/docs/tutorial/doc/bnceh.html
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


SCJP 5 , SCWCD 5, SCEA 5
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Clarification regarding JMS msg Consumer vs Msg Listener