You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by chris24 <il...@gmail.com> on 2006/05/10 18:45:14 UTC

Getting a list of active topics from a JMS client

Hello,

   I have a Java client connecting directly to the broker and am wondering
how I can get a list of topics currently on the broker? I assume the
solution will involve jndi (would this get dynamic topics?). Thanks,

Chris
--
View this message in context: http://www.nabble.com/Getting-a-list-of-active-topics-from-a-JMS-client-t1593110.html#a4323409
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Getting a list of active topics from a JMS client

Posted by chris24 <il...@gmail.com>.
I will look into running an embedded broker. Hopefully, stakeholders don't
take issue with that. I appreciate your help.
--
View this message in context: http://www.nabble.com/Getting-a-list-of-active-topics-from-a-JMS-client-t1593110.html#a4340398
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Getting a list of active topics from a JMS client

Posted by James Strachan <ja...@gmail.com>.
On 5/10/06, chris24 <il...@gmail.com> wrote:
>
> If I try to copy those examples in my Java code, I get address already in use
> errors. I apologize if I am missing something here. Should I point embedded
> broker code the running mq instance (i.e. tcp://XXXXX)?

So try using a different port.

Note that those examples create a new broker - so stop the other
broker thats running (the one I think you were starting via JNDI)

> Environment:
> I currently start the mq broker on it's own using activemq, then I run the
> code I posted in the previous post to connect and publish and subscribe. I
> need to be able to present a list of topics on the client side so the user
> can select what they want to subscribe to.

I'd run an embedded broker for now - its easier. Another option is to
connect remotely to the remote broker using a JMX connector. So you'd
use the JMX API to query the queues on a possibly remote broker

--

James
-------
http://radio.weblogs.com/0112098/

Re: Getting a list of active topics from a JMS client

Posted by chris24 <il...@gmail.com>.
If I try to copy those examples in my Java code, I get address already in use
errors. I apologize if I am missing something here. Should I point embedded
broker code the running mq instance (i.e. tcp://XXXXX)?

Environment:
I currently start the mq broker on it's own using activemq, then I run the
code I posted in the previous post to connect and publish and subscribe. I
need to be able to present a list of topics on the client side so the user
can select what they want to subscribe to.
--
View this message in context: http://www.nabble.com/Getting-a-list-of-active-topics-from-a-JMS-client-t1593110.html#a4329044
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Getting a list of active topics from a JMS client

Posted by James Strachan <ja...@gmail.com>.
On 5/10/06, chris24 <il...@gmail.com> wrote:
>
> How would I get access to a broker object or a region object in my client
> code? I currently connect to the standalone broker like this (using the
> default jndi properties with some new topics):
>         // Obtain a JNDI connection
>         mJndi = new InitialContext();
>
>         // Look up a JMS connection factory
>         TopicConnectionFactory conFactory =
>         (TopicConnectionFactory)mJndi.lookup("TopicConnectionFactory");
>
>         // Create a JMS connection
>         TopicConnection connection =
>         conFactory.createTopicConnection();

See the examples here using Java or Spring...

http://activemq.org/How+do+I+embed+a+Broker+inside+a+Connection

--

James
-------
http://radio.weblogs.com/0112098/

Re: Getting a list of active topics from a JMS client

Posted by chris24 <il...@gmail.com>.
How would I get access to a broker object or a region object in my client
code? I currently connect to the standalone broker like this (using the
default jndi properties with some new topics):
    	// Obtain a JNDI connection
        mJndi = new InitialContext();
 
        // Look up a JMS connection factory
        TopicConnectionFactory conFactory =
        (TopicConnectionFactory)mJndi.lookup("TopicConnectionFactory");
 
        // Create a JMS connection
        TopicConnection connection =
        conFactory.createTopicConnection();

Thanks
--
View this message in context: http://www.nabble.com/Getting-a-list-of-active-topics-from-a-JMS-client-t1593110.html#a4328573
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Getting a list of active topics from a JMS client

Posted by James Strachan <ja...@gmail.com>.
On 5/10/06, chris24 <il...@gmail.com> wrote:
>
> Thanks.Can you get access to the list programmatically? The broker runs
> standalone and the Java client connects to it using JNDI. Is there a way to
> access the broker in code without embedding it in the code?

Some details of how to do it programmatically are here
http://goopen.org/confluence/display/ACTIVEMQ/How+can+I+see+what+destinations+are+used

--

James
-------
http://radio.weblogs.com/0112098/

Re: Getting a list of active topics from a JMS client

Posted by chris24 <il...@gmail.com>.
Thanks.Can you get access to the list programmatically? The broker runs
standalone and the Java client connects to it using JNDI. Is there a way to
access the broker in code without embedding it in the code?
--
View this message in context: http://www.nabble.com/Getting-a-list-of-active-topics-from-a-JMS-client-t1593110.html#a4327195
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Getting a list of active topics from a JMS client

Posted by James Strachan <ja...@gmail.com>.
On 5/10/06, chris24 <il...@gmail.com> wrote:
>
> Hello,
>
>    I have a Java client connecting directly to the broker and am wondering
> how I can get a list of topics currently on the broker? I assume the
> solution will involve jndi (would this get dynamic topics?). Thanks,

The easiest way is to use JMX

http://activemq.org/JMX

though you can also get all of the active destinations from the broker
http://activemq.codehaus.org/maven/apidocs/org/apache/activemq/broker/Broker.html#getDestinations()
http://activemq.codehaus.org/maven/apidocs/org/apache/activemq/broker/region/Region.html#getDestinationMap()
--

James
-------
http://radio.weblogs.com/0112098/