File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clarification regarding JMS msg Consumer vs Msg Listener

 
hildich kilal
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 471
4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 180
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic