ActiveMQ purpose two ways of consumption :
- Consuming asynchronously by calling
MessageListener
- Consuming synchronously by enqueueing and let the client calling
receive()
First I was using @JmsListener
. This annotation makes Spring create an asynchronous consumer, i.e. it makes a receive()
on the queue.
I tried to use MessageListener
but Spring goes on to create an synchronous consumer.
So I looked Spring JMS and ActiveMQ code.
The only way to create an asynchronous consumer is to call ActiveMQSession.createConsumer
with a MessageListener
:
public MessageConsumer createConsumer(Destination destination, MessageListener messageListener) throws JMSException {
return createConsumer(destination, null, messageListener);
}
Then I looked for calls like that one on Spring JMS and I've found nothing.
For the moment, I think that Spring JMS is not able to create a consumer with a MessageListener
, i.e. to create a synchronous consumer (as the first consumption way above).
Am I right?