我们正在将应用程序从 Jboss 5 迁移到 jboss 7。在此我们需要更改 JMS 的 JNDI 查找。
在 Jboss 5 中,它是由 -
InitialContext ic = new InitialContext();
Object obj = ic.lookup(listenerName);
// listenerName has our destination queue name
在 Jboss 7 中,我们正在尝试 -
Properties jndiProps = new Properties();
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProps.put(Context.PROVIDER_URL,"http-remoting://localhost:8080");
jndiProps.put("jboss.naming.client.ejb.context", new Boolean(true));
InitialContext ic = new InitialContext(jndiProps);
Object obj = ic.lookup("jms/queue/" + listenerName);
在 Standalone-full.xml 我们添加了目标队列 -
<jms-queue name="CORESERVICES.DEMO_QUEUE" entries="java:/jms/queue/CORESERVICES.DEMO_QUEUE"/>
我们收到这些错误 -
2017-03-31 15:44:04,056 INFO [com.praval.services.core.msg.MessageRouterMDB] (Thread-16 (ActiveMQ-client-global-threads-1938238098)) PRAVAL jmsQueueName is CORESERVICES.DEMO_QUEUE
2017-03-31 15:44:04,195 INFO [org.jboss.ejb.client.remoting] (Remoting "config-based-naming-client-endpoint" task-6) EJBCLIENT000017: Received server version 2 and marshalling strategies [river]
2017-03-31 15:44:04,203 INFO [org.jboss.ejb.client.remoting] (Thread-16 (ActiveMQ-client-global-threads-1938238098)) EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@13279398, receiver=Remoting connection EJB receiver [connection=Remoting connection <3a06c684>,channel=jboss.ejb,nodename=pravalsharma]} on channel Channel ID 45654a55 (outbound) of Remoting connection 12baae23 to localhost/127.0.0.1:8080
2017-03-31 15:44:04,302 WARNING [com.praval.services.core.msg.MessageRouterMDB] (Thread-16 (ActiveMQ-client-global-threads-1938238098)) javax.naming.NameNotFoundException: jms/queue/CORESERVICES.DEMO_QUEUE -- service jboss.naming.context.java.jboss.exported.jms.queue."CORESERVICES.DEMO_QUEUE"
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:106)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:184)
at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127)
at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)