You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by shaf <sh...@gmail.com> on 2008/05/08 01:53:01 UTC
AMQ 5.1 - How to get a list of Queues
Hello,
I am trying to get a list of existing Queues with the following code:
ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory( server );
ActiveMQConnection amqcon = connectionFactory.createConnection();
Set<ActiveMQQueue> amqs = amqcon.getDestinationSource().getQueues();
Iterator<ActiveMQQueue> queues = amqs.iterator();
while ( queues.hasNext() )
{
ActiveMQQueue queue = queues.next();
System.out.println( "Queue: " + queue.getPhysicalName() );
}
The code above does not work consistently. I have a sample queue as well as
one that I created using the admin interface and none show up. Can someone
provide some guidance here please.
Thanks,
Shaf.
--
View this message in context: http://www.nabble.com/AMQ-5.1---How-to-get-a-list-of-Queues-tp17117156s2354p17117156.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: AMQ 5.1 - How to get a list of Queues
Posted by JuliusR <ju...@yahoo.com.ph>.
Hi,
How to convert these to C#.. thank you.
shaf wrote:
>
> Hello,
>
> I am trying to get a list of existing Queues with the following code:
>
> ActiveMQConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory( server );
> ActiveMQConnection amqcon = connectionFactory.createConnection();
> Set<ActiveMQQueue> amqs = amqcon.getDestinationSource().getQueues();
> Iterator<ActiveMQQueue> queues = amqs.iterator();
>
> while ( queues.hasNext() )
> {
> ActiveMQQueue queue = queues.next();
> System.out.println( "Queue: " + queue.getPhysicalName() );
> }
>
> The code above does not work consistently. I have a sample queue as well
> as one that I created using the admin interface and none show up. Can
> someone provide some guidance here please.
>
> Thanks,
> Shaf.
>
--
View this message in context: http://www.nabble.com/AMQ-5.1---How-to-get-a-list-of-Queues-tp17117156p20086143.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: AMQ 5.1 - How to get a list of Queues
Posted by James Strachan <ja...@gmail.com>.
2008/6/25 shaf <sh...@gmail.com>:
>
> Gents,
>
> I am really having a hard time trying to get a list of queues
> programmatically (Java). I have seen the DestinationSource (
> connection.getDestinationSource() ) working on my local laptop but when
> deployed onto the server environment, it returns a null for some reason and
> I know there are queues available.
It takes some time for all the destinations to arrive from the server
- have you tried waiting a few seconds?
Have you read this?
http://activemq.apache.org/how-do-i-create-new-destinations.html
i.e. are you sure there are queues on the server with messages in them?
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com
Re: AMQ 5.1 - How to get a list of Queues
Posted by shaf <sh...@gmail.com>.
Gents,
I am really having a hard time trying to get a list of queues
programmatically (Java). I have seen the DestinationSource (
connection.getDestinationSource() ) working on my local laptop but when
deployed onto the server environment, it returns a null for some reason and
I know there are queues available.
Based on this thread (as Joe stated) that the DestinationSource link is
broken, and I really need a way of browsing the queues, any suggestions
greatly appreciated!!!!
-shaf.
Mario Siegenthaler-2 wrote:
>
> If you really want to create and list queues you could use the
> JMX-interface to the broker and call the addQueue method on the
> Broker-MBean. That does create an empty queue.
>
> Mario
>
> On Wed, Jun 25, 2008 at 3:20 PM, James Strachan
> <ja...@gmail.com> wrote:
>> 2008/5/8 shaf <sh...@gmail.com>:
>>>
>>> Thanks guys, so when I try to create a Queue using the following:
>>>
>>> ActiveMQSession session =
>>> this.con.getConnection().createSession(false,
>>> Session.AUTO_ACKNOWLEDGE);
>>> // create queue
>>> Queue request = session.createQueue( name );
>>> System.out.println("The queue has been created: " +
>>> request.getQueueName()
>>> );
>>> Thread.sleep( 3000 );
>>>
>>> An then I try to list the queues in the previous code snippet, it does
>>> not
>>> show up. When I try using the admin console, I still dont see the queue
>>> that
>>> I created! Is there something wrong or is this a bug??
>>
>> No this is not a bug - please read
>> http://activemq.apache.org/how-do-i-create-new-destinations.html
>>
>>
>> --
>> James
>> -------
>> http://macstrac.blogspot.com/
>>
>> Open Source Integration
>> http://open.iona.com
>>
>
>
--
View this message in context: http://www.nabble.com/AMQ-5.1---How-to-get-a-list-of-Queues-tp17117156p18116111.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: AMQ 5.1 - How to get a list of Queues
Posted by Mario Siegenthaler <ms...@inventsoft.ch>.
If you really want to create and list queues you could use the
JMX-interface to the broker and call the addQueue method on the
Broker-MBean. That does create an empty queue.
Mario
On Wed, Jun 25, 2008 at 3:20 PM, James Strachan
<ja...@gmail.com> wrote:
> 2008/5/8 shaf <sh...@gmail.com>:
>>
>> Thanks guys, so when I try to create a Queue using the following:
>>
>> ActiveMQSession session = this.con.getConnection().createSession(false,
>> Session.AUTO_ACKNOWLEDGE);
>> // create queue
>> Queue request = session.createQueue( name );
>> System.out.println("The queue has been created: " + request.getQueueName()
>> );
>> Thread.sleep( 3000 );
>>
>> An then I try to list the queues in the previous code snippet, it does not
>> show up. When I try using the admin console, I still dont see the queue that
>> I created! Is there something wrong or is this a bug??
>
> No this is not a bug - please read
> http://activemq.apache.org/how-do-i-create-new-destinations.html
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://open.iona.com
>
Re: AMQ 5.1 - How to get a list of Queues
Posted by James Strachan <ja...@gmail.com>.
2008/5/8 shaf <sh...@gmail.com>:
>
> Thanks guys, so when I try to create a Queue using the following:
>
> ActiveMQSession session = this.con.getConnection().createSession(false,
> Session.AUTO_ACKNOWLEDGE);
> // create queue
> Queue request = session.createQueue( name );
> System.out.println("The queue has been created: " + request.getQueueName()
> );
> Thread.sleep( 3000 );
>
> An then I try to list the queues in the previous code snippet, it does not
> show up. When I try using the admin console, I still dont see the queue that
> I created! Is there something wrong or is this a bug??
No this is not a bug - please read
http://activemq.apache.org/how-do-i-create-new-destinations.html
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com
Re: AMQ 5.1 - How to get a list of Queues
Posted by James Strachan <ja...@gmail.com>.
2008/5/8 shaf <sh...@gmail.com>:
>
> Thanks guys, so when I try to create a Queue using the following:
>
> ActiveMQSession session = this.con.getConnection().createSession(false,
> Session.AUTO_ACKNOWLEDGE);
> // create queue
> Queue request = session.createQueue( name );
> System.out.println("The queue has been created: " + request.getQueueName()
> );
> Thread.sleep( 3000 );
>
> An then I try to list the queues in the previous code snippet, it does not
> show up. When I try using the admin console, I still dont see the queue that
> I created! Is there something wrong or is this a bug??
Creating queues on the client do not create broker side queues until
you send a message to them.
http://activemq.apache.org/how-do-i-create-new-destinations.html
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com
Re: AMQ 5.1 - How to get a list of Queues
Posted by shaf <sh...@gmail.com>.
Thanks guys, so when I try to create a Queue using the following:
ActiveMQSession session = this.con.getConnection().createSession(false,
Session.AUTO_ACKNOWLEDGE);
// create queue
Queue request = session.createQueue( name );
System.out.println("The queue has been created: " + request.getQueueName()
);
Thread.sleep( 3000 );
An then I try to list the queues in the previous code snippet, it does not
show up. When I try using the admin console, I still dont see the queue that
I created! Is there something wrong or is this a bug??
-Shaf.
James.Strachan wrote:
>
> BTW you can listen to destinations being added/removed by calling the
> setDestinationListener method on the DestinationSource
>
>
>
> 2008/5/8 shaf <sh...@gmail.com>:
>>
>> Hello,
>>
>> I am trying to get a list of existing Queues with the following code:
>>
>> ActiveMQConnectionFactory connectionFactory = new
>> ActiveMQConnectionFactory( server );
>> ActiveMQConnection amqcon = connectionFactory.createConnection();
>> Set<ActiveMQQueue> amqs =
>> amqcon.getDestinationSource().getQueues();
>> Iterator<ActiveMQQueue> queues = amqs.iterator();
>>
>> while ( queues.hasNext() )
>> {
>> ActiveMQQueue queue = queues.next();
>> System.out.println( "Queue: " + queue.getPhysicalName()
>> );
>> }
>>
>> The code above does not work consistently. I have a sample queue as well
>> as
>> one that I created using the admin interface and none show up. Can
>> someone
>> provide some guidance here please.
>>
>> Thanks,
>> Shaf.
>> --
>> View this message in context:
>> http://www.nabble.com/AMQ-5.1---How-to-get-a-list-of-Queues-tp17117156s2354p17117156.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://open.iona.com
>
>
--
View this message in context: http://www.nabble.com/AMQ-5.1---How-to-get-a-list-of-Queues-tp17117156s2354p17126489.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: AMQ 5.1 - How to get a list of Queues
Posted by shaf <sh...@gmail.com>.
Does anyone know whether this has been fixed? If so, how can I patch my
existing server with the fix (I dont have any build libraries to re-build
the source)?
It is critical for me to have the ability to browse for queues via the Java
API's
Thanks,
shaf.
ttmdev wrote:
>
> FYI - the "Destination" link @ the top of
> http://activemq.apache.org/activemq-510-release.html is broken.
>
> Joe
>
>
> James.Strachan wrote:
>>
>> BTW you can listen to destinations being added/removed by calling the
>> setDestinationListener method on the DestinationSource
>>
>>
>>
>> 2008/5/8 shaf <sh...@gmail.com>:
>>>
>>> Hello,
>>>
>>> I am trying to get a list of existing Queues with the following code:
>>>
>>> ActiveMQConnectionFactory connectionFactory = new
>>> ActiveMQConnectionFactory( server );
>>> ActiveMQConnection amqcon =
>>> connectionFactory.createConnection();
>>> Set<ActiveMQQueue> amqs =
>>> amqcon.getDestinationSource().getQueues();
>>> Iterator<ActiveMQQueue> queues = amqs.iterator();
>>>
>>> while ( queues.hasNext() )
>>> {
>>> ActiveMQQueue queue = queues.next();
>>> System.out.println( "Queue: " + queue.getPhysicalName()
>>> );
>>> }
>>>
>>> The code above does not work consistently. I have a sample queue as
>>> well as
>>> one that I created using the admin interface and none show up. Can
>>> someone
>>> provide some guidance here please.
>>>
>>> Thanks,
>>> Shaf.
>>> --
>>> View this message in context:
>>> http://www.nabble.com/AMQ-5.1---How-to-get-a-list-of-Queues-tp17117156s2354p17117156.html
>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> James
>> -------
>> http://macstrac.blogspot.com/
>>
>> Open Source Integration
>> http://open.iona.com
>>
>>
>
>
--
View this message in context: http://www.nabble.com/AMQ-5.1---How-to-get-a-list-of-Queues-tp17117156p18112068.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: AMQ 5.1 - How to get a list of Queues
Posted by ttmdev <jo...@ttmsolutions.com>.
FYI - the "Destination" link @ the top of
http://activemq.apache.org/activemq-510-release.html is broken.
Joe
James.Strachan wrote:
>
> BTW you can listen to destinations being added/removed by calling the
> setDestinationListener method on the DestinationSource
>
>
>
> 2008/5/8 shaf <sh...@gmail.com>:
>>
>> Hello,
>>
>> I am trying to get a list of existing Queues with the following code:
>>
>> ActiveMQConnectionFactory connectionFactory = new
>> ActiveMQConnectionFactory( server );
>> ActiveMQConnection amqcon = connectionFactory.createConnection();
>> Set<ActiveMQQueue> amqs =
>> amqcon.getDestinationSource().getQueues();
>> Iterator<ActiveMQQueue> queues = amqs.iterator();
>>
>> while ( queues.hasNext() )
>> {
>> ActiveMQQueue queue = queues.next();
>> System.out.println( "Queue: " + queue.getPhysicalName()
>> );
>> }
>>
>> The code above does not work consistently. I have a sample queue as well
>> as
>> one that I created using the admin interface and none show up. Can
>> someone
>> provide some guidance here please.
>>
>> Thanks,
>> Shaf.
>> --
>> View this message in context:
>> http://www.nabble.com/AMQ-5.1---How-to-get-a-list-of-Queues-tp17117156s2354p17117156.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://open.iona.com
>
>
--
View this message in context: http://www.nabble.com/AMQ-5.1---How-to-get-a-list-of-Queues-tp17117156s2354p17125731.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: AMQ 5.1 - How to get a list of Queues
Posted by James Strachan <ja...@gmail.com>.
BTW you can listen to destinations being added/removed by calling the
setDestinationListener method on the DestinationSource
2008/5/8 shaf <sh...@gmail.com>:
>
> Hello,
>
> I am trying to get a list of existing Queues with the following code:
>
> ActiveMQConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory( server );
> ActiveMQConnection amqcon = connectionFactory.createConnection();
> Set<ActiveMQQueue> amqs = amqcon.getDestinationSource().getQueues();
> Iterator<ActiveMQQueue> queues = amqs.iterator();
>
> while ( queues.hasNext() )
> {
> ActiveMQQueue queue = queues.next();
> System.out.println( "Queue: " + queue.getPhysicalName() );
> }
>
> The code above does not work consistently. I have a sample queue as well as
> one that I created using the admin interface and none show up. Can someone
> provide some guidance here please.
>
> Thanks,
> Shaf.
> --
> View this message in context: http://www.nabble.com/AMQ-5.1---How-to-get-a-list-of-Queues-tp17117156s2354p17117156.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com
Re: AMQ 5.1 - How to get a list of Queues
Posted by kpalania <kp...@yahoo.com>.
Take a look at this thread for a potential solution:
http://www.nabble.com/%28Solved%29-Discovering-queues-programmatically-and-dequeuing-messages-off-of-them-tt19538405.html
kpalania wrote:
>
>
> James.Strachan wrote:
>>
>> It does take a little while for some destinations to show up as they
>> are typically loaded asynchronously on the JMS client - does sleeping
>> for a second or so help?
>>
>
> I believe this is the same problem that I am running into. Is this a bug?
>
--
View this message in context: http://www.nabble.com/AMQ-5.1---How-to-get-a-list-of-Queues-tp17117156p19555977.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: AMQ 5.1 - How to get a list of Queues
Posted by kpalania <kp...@yahoo.com>.
James.Strachan wrote:
>
> It does take a little while for some destinations to show up as they
> are typically loaded asynchronously on the JMS client - does sleeping
> for a second or so help?
>
I believe this is the same problem that I am running into. Is this a bug?
--
View this message in context: http://www.nabble.com/AMQ-5.1---How-to-get-a-list-of-Queues-tp17117156p19555220.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: AMQ 5.1 - How to get a list of Queues
Posted by James Strachan <ja...@gmail.com>.
It does take a little while for some destinations to show up as they
are typically loaded asynchronously on the JMS client - does sleeping
for a second or so help?
2008/5/8 shaf <sh...@gmail.com>:
>
> Hello,
>
> I am trying to get a list of existing Queues with the following code:
>
> ActiveMQConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory( server );
> ActiveMQConnection amqcon = connectionFactory.createConnection();
> Set<ActiveMQQueue> amqs = amqcon.getDestinationSource().getQueues();
> Iterator<ActiveMQQueue> queues = amqs.iterator();
>
> while ( queues.hasNext() )
> {
> ActiveMQQueue queue = queues.next();
> System.out.println( "Queue: " + queue.getPhysicalName() );
> }
>
> The code above does not work consistently. I have a sample queue as well as
> one that I created using the admin interface and none show up. Can someone
> provide some guidance here please.
>
> Thanks,
> Shaf.
> --
> View this message in context: http://www.nabble.com/AMQ-5.1---How-to-get-a-list-of-Queues-tp17117156s2354p17117156.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com
Re: AMQ 5.1 - How to get a list of Queues
Posted by James Strachan <ja...@gmail.com>.
2008/8/12 kpalania <kp...@yahoo.com>:
>
> I can't seem to find the DestinationSource class -
>
> http://activemq.apache.org/maven/activemq-core/apidocs/
>
> Has this been deprecated?
No its just the javadoc hasn't been redeployed in a while
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com
Re: AMQ 5.1 - How to get a list of Queues
Posted by kpalania <kp...@yahoo.com>.
I can't seem to find the DestinationSource class -
http://activemq.apache.org/maven/activemq-core/apidocs/
Has this been deprecated?
jlim wrote:
>
> Hi Shaf,
>
> Just tested this on 5.1.0 and seems to work fine on my test. I tested
> this using startup destinations
> (http://activemq.apache.org/configure-startup-destinations.html) and
> also creating one via jmx.
>
> Can you look in jconsole (or any jmx console) to see if the queues are
> actually created?
>
> Regards,
> Jonas
>
> shaf wrote:
>> Hello,
>>
>> I am trying to get a list of existing Queues with the following code:
>>
>> ActiveMQConnectionFactory connectionFactory = new
>> ActiveMQConnectionFactory( server );
>> ActiveMQConnection amqcon = connectionFactory.createConnection();
>> Set<ActiveMQQueue> amqs = amqcon.getDestinationSource().getQueues();
>> Iterator<ActiveMQQueue> queues = amqs.iterator();
>>
>> while ( queues.hasNext() )
>> {
>> ActiveMQQueue queue = queues.next();
>> System.out.println( "Queue: " + queue.getPhysicalName() );
>> }
>>
>> The code above does not work consistently. I have a sample queue as well
>> as
>> one that I created using the admin interface and none show up. Can
>> someone
>> provide some guidance here please.
>>
>> Thanks,
>> Shaf.
>>
>
>
--
View this message in context: http://www.nabble.com/AMQ-5.1---How-to-get-a-list-of-Queues-tp17117156p18946046.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: AMQ 5.1 - How to get a list of Queues
Posted by Jonas Lim <jl...@exist.com>.
Hi Shaf,
Just tested this on 5.1.0 and seems to work fine on my test. I tested
this using startup destinations
(http://activemq.apache.org/configure-startup-destinations.html) and
also creating one via jmx.
Can you look in jconsole (or any jmx console) to see if the queues are
actually created?
Regards,
Jonas
shaf wrote:
> Hello,
>
> I am trying to get a list of existing Queues with the following code:
>
> ActiveMQConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory( server );
> ActiveMQConnection amqcon = connectionFactory.createConnection();
> Set<ActiveMQQueue> amqs = amqcon.getDestinationSource().getQueues();
> Iterator<ActiveMQQueue> queues = amqs.iterator();
>
> while ( queues.hasNext() )
> {
> ActiveMQQueue queue = queues.next();
> System.out.println( "Queue: " + queue.getPhysicalName() );
> }
>
> The code above does not work consistently. I have a sample queue as well as
> one that I created using the admin interface and none show up. Can someone
> provide some guidance here please.
>
> Thanks,
> Shaf.
>