我想使用JMS连接到IBM MQ。
如何指定队列管理器, channel 和其他属性?
最佳答案
使用JNDI进行connectionFactory/目的地查询,为InitialContext
提供以下属性:
java.naming.provider.url=<ip>:<port, default is 1414>/<channel name, default channel is SYSTEM.DEF.SVRCONN>
java.naming.factory.initial=com.ibm.mq.jms.context.WMQInitialContextFactory
java.naming.security.authentication=none
java.naming.security.credentials=
java.naming.security.principal=
使用WAS(Websphere应用程序服务器)队列,属性将如下所示:
java.naming.provider.url=iiop://<ip>:<port, the defualt is 2809>
java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory
java.naming.security.authentication=none
java.naming.security.credentials=
java.naming.security.principal=
其余的如下:
Properties config = new Properties();
config.load(new FileInputStream("connectionConfig.properties"));// this file would contain the properties above
InitialContext context = new InitialContext(config);
ConnectionFactory factory = (ConnectionFactory) context.lookup("ConnectionFactory");// connection factory name
Destination destination = (Destination) context.lookup("destination");// queue/topic name
关于jms - 使用JMS连接到IBM MQ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2324038/