我在本地安装了openMQ,它工作正常。我使用以下代码来QueueConnectionFactory
使用 JNDI 查找。
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");
env.put(Context.PROVIDER_URL, "file:///C:/objectstore");
Context ctx = new InitialContext(env);
QueueConnectionFactory myFactory = (QueueConnectionFactory) ctx.lookup("MyQueueConnection");
上面返回了连接工厂,我也可以从中访问replyQueue
and requestQueue
。
这就是我设置队列的方式
imqobjmgr add -l "MyQueueConnection"" -j "java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContext
Factory" -j "java.naming.provider.url=file:///C://objectstore" -t qf -o "imqAddressList=mq://localhost:7676/jms"
imqobjmgr add -l "cn=DEVL.REQUEST" -j "java.naming.factory.initial=com.sun.jndi.fscontext.RefFSCon
textFactory" -j "java.naming.provider.url=file:///C://objectstore" -t q -o "imqDestinationName=requestQueue"
imqobjmgr add -l "cn=DEVL.REPLY" -j "java.naming.factory.initial=com.sun.jndi.fscontext.RefFSConte
xtFactory" -j "java.naming.provider.url=file:///C://objectstore" -t q -o "imqDestinationName=replyQueue"
我的问题是:
如何在 linux 服务器上设置 openMQ,以便我可以从另一个服务器访问 openMQ,其中代码将在 tomcat apache 服务器(也是一个 linux 机器)中运行。
我必须对代码进行哪些更改才能从 位于不同服务器上的
QueueConnectionFactory
openMQ获取?
我没有在 GlassFish 中运行 openMQ,而是自己运行 openMQ (imqbrokerd.exe)。