[ 
https://issues.apache.org/jira/browse/AMQ-8371?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

john lilley updated AMQ-8371:
-----------------------------
    Description: 
I desire to programatically purge all queues, either as an administrative 
function or during dev/test to get a clean system.

Following inline examples, I've written code like;

 
{code:java}
ActiveMQConnectionFactory connectionFactory = new 
ActiveMQConnectionFactory(url);
ActiveMQConnection connection = 
(ActiveMQConnection)connectionFactory.createConnection();
DestinationSource destinationSource = connection.getDestinationSource();
for (ActiveMQQueue queue : destinationSource.getQueues()) {
    connection.destroyDestination(queue);
}{code}
However, getQueues() always returns an empty set, even though there are queues 
visible in the web console.  Looking at the source code, it appears that the 
queues list is only populated by listening for queue-create advisory topic 
messages, so any queues that exist at the time this code is run are not listed.

This would seem to contradict [the 
docs|https://activemq.apache.org/how-can-i-get-a-list-of-the-topics-and-queues-in-a-broker]
 where it says "As of 5.1.0 you can use the new 
[DestinationSource|http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/advisory/DestinationSource.html]
 on an ActiveMQConnection to access the available queues"

  was:
I desire to programatically purge all queues, either as an administrative 
function or during dev/test to get a clean system.

Following inline examples, I've written code like;

 
{code:java}
ActiveMQConnectionFactory connectionFactory = new 
ActiveMQConnectionFactory(url);
ActiveMQConnection connection = 
(ActiveMQConnection)connectionFactory.createConnection();
DestinationSource destinationSource = connection.getDestinationSource();
for (ActiveMQQueue queue : destinationSource.getQueues()) {
    connection.destroyDestination(queue);
}{code}
However, getQueues() always returns an empty set, even though there are queues 
visible in the web console.  Looking at the source code, it appears that the 
queues list is only populated by listening for queue-create advisory topic 
messages, so any queues that exist at the time this code is run are not listed.


> DestinationSource.getQueues() does not enumerate existing queues
> ----------------------------------------------------------------
>
>                 Key: AMQ-8371
>                 URL: https://issues.apache.org/jira/browse/AMQ-8371
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: JMS client
>    Affects Versions: 5.15.12
>            Reporter: john lilley
>            Priority: Major
>
> I desire to programatically purge all queues, either as an administrative 
> function or during dev/test to get a clean system.
> Following inline examples, I've written code like;
>  
> {code:java}
> ActiveMQConnectionFactory connectionFactory = new 
> ActiveMQConnectionFactory(url);
> ActiveMQConnection connection = 
> (ActiveMQConnection)connectionFactory.createConnection();
> DestinationSource destinationSource = connection.getDestinationSource();
> for (ActiveMQQueue queue : destinationSource.getQueues()) {
>     connection.destroyDestination(queue);
> }{code}
> However, getQueues() always returns an empty set, even though there are 
> queues visible in the web console.  Looking at the source code, it appears 
> that the queues list is only populated by listening for queue-create advisory 
> topic messages, so any queues that exist at the time this code is run are not 
> listed.
> This would seem to contradict [the 
> docs|https://activemq.apache.org/how-can-i-get-a-list-of-the-topics-and-queues-in-a-broker]
>  where it says "As of 5.1.0 you can use the new 
> [DestinationSource|http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/advisory/DestinationSource.html]
>  on an ActiveMQConnection to access the available queues"



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to