Reputation: 1
I have 2 queues in rabbitMQ, queueA
and queueB
when queueA
and/or queueB
is filled with data( via convertAndSend()
method), it will automatically call MessageListener.onMessage()
Method (CMIIW).
So, my question is, how can I call methodA()
, when queueA
is filled, and call methodB()
when queueB
is filled.
Different Method for Different queue
Upvotes: 0
Views: 384
Reputation: 174819
See the documentation.
You can use two listener containers (one for each queue) and use a MessageListenerAdapter
configured to call the appropriate method for each queue (see setDefaultListenerMethod()
).
You can use a single listener container that listens to both queues, and subclass MessageListenerAdapter
and implement getListenerMethodName()
to determine which method to call based on the message. Starting with Spring AMQP version 1.4.2, the queue from which a message was received is available in
originalMessage.getMessageProperties().get(AmqpHeaders.CONSUMER_QUEUE)
Upvotes: 1