You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by tlien <tg...@yahoo.com> on 2013/03/21 21:38:09 UTC
JMS Topic External Lookup
Trying to lookup my "testtopic" in a JVM outside the container, but it
returns null.
I found a previous discussion about this here
(http://openejb.979440.n4.nabble.com/Remote-JNDI-access-to-JMS-resources-td4656767.html).
I tried to set everything up as suggested but maybe I missed something. I
tried using tomee 1.5.1 and also with latest snapshot with the same results.
SERVER CONFIG (tomee.xml):
<Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
BrokerXmlConfig = broker:(tcp://localhost:61616)
ServerUrl = tcp://localhost:61616
</Resource>
<Resource id="MyJmsConnectionFactory" type="javax.jms.ConnectionFactory">
ResourceAdapter = MyJmsResourceAdapter
</Resource>
<Resource id="testtopic" type="javax.jms.Topic"/>
CLIENT:
JARS IN CLASSPATH:
openejb-core,javaee-api,slf4j-api,sl4j-jdk14,activemq-core
import javax.jms.Topic;
import javax.naming.InitialContext;
import javax.naming.NameClassPair;
import javax.naming.NamingEnumeration;
public class JndiLookupTest {
public static void main(String[] args) throws Exception {
System.setProperty("java.naming.factory.initial",
"org.apache.openejb.client.RemoteInitialContextFactory");
System.setProperty("java.naming.provider.url",
"http://127.0.0.1:8080/tomee/ejb");
System.setProperty("Resource/javax.jms.ConnectionFactory",
"connectionfactory:org.apache.activemq.ActiveMQConnectionFactory:tcp://localhost:61616");
InitialContext context = new InitialContext();
Object o = context.lookup("MyJmsConnectionFactory");
System.out.println("ConnectionFactory: " + o);
Topic t = (Topic)context.lookup("testtopic");
System.out.println("Topic: " + t);
System.out.println();
System.out.println("Available Topics:");
NamingEnumeration<NameClassPair> list = context.list("");
while (list.hasMore()) {
System.out.println(list.next().getName());
}
}
}
PROGRAM OUTPUT:
Mar 21, 2013 3:24:16 PM org.apache.openejb.client.EventLogger log
INFO:
RemoteInitialContextCreated{providerUri=http://127.0.0.1:8080/tomee/ejb}
ConnectionFactory: org.apache.activemq.ActiveMQConnectionFactory@1233caf
Topic: null
Available Topics:
.
openejb
MEJB
--
View this message in context: http://openejb.979440.n4.nabble.com/JMS-Topic-External-Lookup-tp4661664.html
Sent from the OpenEJB User mailing list archive at Nabble.com.