This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
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: 392
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
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.