activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian Co <...@exist.com>
Subject Re: how to lookup a topicName dynamically
Date Wed, 28 Mar 2007 22:50:10 GMT
IMO, using BrokerService.getDestinations() will only work when you are 
using embedded brokers. I.e. you are deploying the JMS broker inside 
your app and you have access to the BrokerService object.

If you want to access a remote broker (i.e. if you run it via 
./activemq), you need to use JMX and call the getTopics, getQueues, etc 
of the BrokerViewMBean.

Hope that helps.


new2activemq wrote:
> James,
>
> thanks a lot for your help below. i was actually able to try the list()
> method and it lists everything that's in my jndi.properties file. i think
> the reason is that my InitalContext in the first place does a 'lookup' in
> the jndi.properties file.
>
> however, lets say my activemq broker is running and thru the jmx console i
> add a new topic on the fly - this new topic name will NOT be in my
> jndi.properties. however, yes - it does now exist on the broker. so to work
> in this scenario, i'm trying to get a list of destinations that are active
> directly from the broker.
>
> in interface Broker there is a method called getDestinations() - some of the
> classes that implement this interface, for example BrokerBroadcaster,
> RegionBroker, etc. "may help" me in doing what i want to do... but i'm not
> sure exactly how to use them... any ideas? class BrokerService also has a
> getDestinations() method.
>
> the problem i'm having is that when invoke the getBrokerName() method of
> class BrokerService, it returns a "null". because its a null i am not sure
> how to proceed further.
>
> on the other hand, when i invoke the getBrokerURL() method of class 
> ActiveMQConnectionFactory - it does return the expected result: 
> "tcp://localhost:61616
>
> any further guidance from you on how i may accomplish my task with the above
> information (or any other which i may be missing) will be highly
> appreciated.
>
>  Thanks!
>
>
> James.Strachan wrote:
>   
>> try the JNDI javadoc
>> http://java.sun.com/j2se/1.5.0/docs/api/javax/naming/InitialContext.html#list(java.lang.String)
>>
>> or a Sun tutorial on JNDI
>>
>>
>> On 3/22/07, new2activemq <ahuja@avaya.com> wrote:
>>     
>>> Hi,
>>>
>>> I am trying to write a debug tool where as a user, I do not know the
>>> topicNames that exist. Normally, if I knew the topic name, I could just
>>> do
>>> this:
>>>
>>> myContext.lookup(jndiName)
>>>
>>> where jndiName is the topicName
>>>
>>> Is there a way I can pass in an argument, or a wildcard argument that
>>> will
>>> look up all the topicNames that exist? Or is it possible that there is an
>>> all different way to do this?
>>>
>>> Any help will be greatly appreciated.
>>>
>>> Thanks!
>>> --
>>> View this message in context:
>>> http://www.nabble.com/how-to-lookup-a-topicName-dynamically-tf3449350s2354.html#a9620849
>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>>
>>>
>>>       
>> -- 
>>
>> James
>> -------
>> http://radio.weblogs.com/0112098/
>>
>>
>>     
>
>   


Mime
View raw message