【发布时间】:2015-12-26 05:54:26
【问题描述】:
我想使用绑定文件配置 Java 应用程序以使用 JMS IBM MQ 队列。 我正在使用 IBM 提供的 JMSDEMO 应用程序。 它适用于本地 MQ 管理器,但我无法使其连接到远程管理器。 我已经在远程机器上生成了绑定文件并将其复制到我的机器上。
我已将绑定文件中的“localhost”更改为远程机器名称。 但是,该应用程序仍然认为它应该连接到本地 QM。 (实际上它忽略了主机名设置)。
这是 IBM 演示代码:
public static final String cfLookup = "JMSDEMOCF";
public static final String JNDITopic = "JMSDEMOTopic";
public static final String JNDIQueue = "JMSDEMOQueue";
public static final String icf ="com.sun.jndi.fscontext.RefFSContextFactory";
........
static String url = "file:C:\\JMSDEMO\\JNDI";
.......
Hashtable environment = new Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY, icf);
environment.put(Context.PROVIDER_URL, url);
ctx = new InitialDirContext( environment );
connFactory = (ConnectionFactory)ctx.lookup( cfLookup );
connection = connFactory.createConnection();
connection.start();
这是绑定文件的一些片段(JMSDEMOCF 是连接工厂的名称)
JMSDEMOCF/RefAddr/3/Content=<the remote machine name or IP; both ignored>
JMSDEMOCF/RefAddr/29/Content=<the remote machine name or IP; both ignored>(the remote port)
它还有下面一行:
JMSDEMOCF/RefAddr/116/Type=XMSC_WMQ_LOCAL_ADDRESS
但删除它不会改变任何事情。
【问题讨论】: