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?
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