Working with multiple queues in ApacheMQ
In the preceding section, we demonstrated sending messages using Map Message to Order Queue. Now, we can have a look at how to work with multiple queues in ApacheMQ:
- Start the Apache ActiveMQ server, and in the console, click on Queues and create two queues.
- Let us create two queues and name the queues as follows:
PacktTestQueue1
PacktTestQueue2
- Create a new Spring project with the same dependency as the first example in the chapter.
- Create a
PacktMessageListener
class that implements theMessageListener
interface. The class overrides theonMessage(Message message)
method. - Spring's
DefaultMessageListener
consumes the messages from the queue and calls theonMessage(Message message)
method.PacktMessageListener: package com.packt.jms; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageListener; import javax.jms.TextMessage; public class PacktMessageListener implements MessageListener{ private PacktMessageSender packtmessagesender...