Karthik Balasubramanian
Karthik Balasubramanian

Reputation: 1157

ActiveMQ - Consuming from Queue and Topic at the same time

We are trying to consume messages in activemq. The producer (of which we have no control) puts the different messages in a Queue and a Topic. As a consumer how could I configure my client to consume from the queue and the topic concurrently? The only way I can think of is to create two different consumers, one connected to the queue and the other connected to the topic. Is this approach correct or is there something that I could do to create one consumer that listens to both at the same time?

Thanks K

Upvotes: 1

Views: 2264

Answers (2)

Tim Bish
Tim Bish

Reputation: 18411

You can achieve this using ActiveMQ's composite destination feature which allows you to listen on more than one destination and on differet types of destinations.

Upvotes: 1

Petter Nordlander
Petter Nordlander

Reputation: 22279

ActiveMQ standard distribution comes bundled with Apache Camel.

Given that you are running the standard ActiveMQ - you could add a small route to Camel that does this for you.

Edit the "camel.xml" int the /conf folder.

Add two routes:

<route>
  <from uri="activemq:topic:someTopic"/>
  <to uri="activemq:queue:comboQueue"/>
</route>

<route>
  <from uri="activemq:queue:someQueue"/>
  <to uri="activemq:queue:comboQueue"/>
</route>

Make sure this camel.xml is included in the ActiveMQ config, such as Activemq.xml.

Now, just consume from "comboQueue" and you get all messages in one place.

Upvotes: 3

Related Questions