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 Thu, 29 Mar 2007 23:29:58 GMT
Well, it really depends on what you what to do with the destination 
information.

You could use the ObjectName to query the mbeanserver to obtain stat 
info about that particular destination.

I think the Destination Object Name contains the Destination attribute, 
which is actually the destination name. So you can easily extract that 
and create an actual destination object to send messages to:

String name = // Get destination name via ObjectName;
ActiveMQQueue q = new ActiveMQQeuue(name);
// Send message to q

Destinations are really just routing information anyways.

Hope this helps.

new2activemq wrote:
> I was able to access the getTopics method of BrokerViewMBean by using the
> "invoke" method on a MBeanServerObject. However, the problem now is that the
> getTopics() method returns an ObjectName[] however the "invoke" method I
> used does not expect an ObjectName[]. If I try simple casting the error goes
> away, but the information is not useful anymore. Is there a workaround for
> this? Thanks for all the help! 
>
>
> Adrian Co wrote:
>   
>> You have to use JMX to access it and enable JMX in activemq.
>>
>> http://java.sun.com/j2se/1.5.0/docs/guide/jmx/tutorial/tutorialTOC.html
>>
>> new2activemq wrote:
>>     
>>> Thanks! That really helps me in putting the effort in the right
>>> direction. I
>>> think in my environment we fall under the second cateogory mentioned
>>> below -
>>> we are accessing remote broker. Also, in my JMX console window... under
>>> "org.apache.activemq" --> "localhost" --> "Broker" --> "Info" I can
see
>>> the
>>> MBean Java Class = org.apache.activemq.broker.jmx.BrokerView. The
>>> BrokerView
>>> implements BrokerViewMBean. The problem that I am having now is that I
>>> don't
>>> know how access the BrokerView object? Am I missing something obviously
>>> simple here? Any guidance on this will be very helpful. Thanks! 
>>>
>>>
>>> Adrian Co wrote:
>>>   
>>>       
>>>> 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