James, I do not add topic to JNDI. What I do is add Topic to ActiveMQ server
remotely through JMX just as the code below :
jmxUrl = new
JMXServiceURL("service:jmx:rmi:///jndi/rmi://10.4.1.64:1099/jmxrmi");
JMXConnector jmxc = JMXConnectorFactory.connect(jmxUrl);
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
ObjectName mBeanName = new
ObjectName("org.apache.activemq:BrokerName=localhost,Type=Broker");
mbsc.invoke(mBeanName, "addTopic",new Object[]{"Hello"}, new String[]
{"java.lang.String"});
mbsc.invoke(mBeanName, "addQueue",new Object[]{"World"}, new String[]
{"java.lang.String"});
And I want to retrieve the topic I just addd. ActiveMQ is running on the
server pc. And the client code is running on the client pc. They are not the
same machine. How can I get the topic ?(I try the client code but it failed
to get the topic)???
James.Strachan wrote:
>
> On 5/11/07, Jiang <[EMAIL PROTECTED]> wrote:
>>
>> I add one topic(name is Hello) use jmx . And I can see the topic through
>> jconsole. But when I use code below to get the destination :
>>
>> Hashtable env = new Hashtable();
>> env.put(Context.INITIAL_CONTEXT_FACTORY,
>> "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
>> env.put(Context.PROVIDER_URL, "tcp://localhost:61616");
>> Context ctx = new InitialContext(env);
>> Destination des = (Destination)ctx.lookup("Hello");
>>
>> It throught Exception like :
>> javax.naming.NameNotFoundException: Hello
>> at
>> org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:215)
>> at javax.naming.InitialContext.lookup(Unknown Source)
>> at JndiTest.start(JndiTest.java:36)
>> at JndiTest.main(JndiTest.java:74)
>>
>> Why I can see the topic but cannot lookup it ???
>
> You don't add topics to JNDI via JMX, you do it by using JNDI
> explicitly yourself or by editing the jndi.properties file
> http://activemq.apache.org/jndi-support.html
> --
> James
> -------
> http://macstrac.blogspot.com/
>
>
--
View this message in context:
http://www.nabble.com/Why-cannot-get-Destination-tf3727216s2354.html#a10445530
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.