tkyass
tkyass

Reputation: 3186

get all queue names for activemq in java

I'm trying to get all the names of the queues for activeMQ in java, I found couple topics here and here about that and people suggested using DestinationSource which I wasn't able to import in Eclipse when I was writing the code. I tried:

import org.apache.activemq.advisory.DestinationSource;

I'm using java 1.7 and latest activemq version 5.14.1. Any ideas if destinationsource is still supported or not? Thanks,

Upvotes: 1

Views: 2091

Answers (2)

Jakub Korab
Jakub Korab

Reputation: 5024

The easiest way to get a handle on this information is by using Jolokia, which is installed by default. To do this, use an HTTP client to issue a GET request to one of the following URIs:

http://localhost:8161/api/jolokia/search/*:destinationType=Queue,*
http://localhost:8161/api/jolokia/search/*:destinationType=Topic,*

You will need to pass in the JMX username and password (default: admin/admin) as part of the HTTP request. The system will respond with something along the lines of:

{ 
  "request" : { 
    "mbean" : "*:destinationType=Queue,*",
    "type" : "search"
  },
  "status" : 200,
  "timestamp" : 1478615354,
  "value" : [ 
    "org.apache.activemq:brokerName=localhost,destinationName=systemX.bar,destinationType=Queue,type=Broker",
    "org.apache.activemq:brokerName=localhost,destinationName=systemX.foo,destinationType=Queue,type=Broker",
    "org.apache.activemq:brokerName=localhost,destinationName=ActiveMQ.DLQ,destinationType=Queue,type=Broker"
  ]
}

The above shows the queues systemX.foo, systemX.bar, ActiveMQ.DLQ. Here's an example of using the curl command for this:

curl -u admin http://localhost:8161/api/jolokia/search/*:destinationType=Queue,* && echo ""

For a good explanation of how to use the Jolokia APIs, refer to the documentation.

Upvotes: 3

Tim Bish
Tim Bish

Reputation: 18356

The feature is still supported in the ActiveMQ project, with the caveat that it may not always work based on comments already given here. If you have advisory support enabled on the Broker then it should provide you with some insight into the destinations that exist, although JMX would give you more management of said destinations.

There's unit tests that show the DestinationSource feature which you can refer to. You need to put the 'activemq-client' jar in the class path so perhaps your IDE project isn't configured properly.

Upvotes: 0

Related Questions