Using JMS to connect to IBM MQ

后端 未结 5 2291
被撕碎了的回忆
被撕碎了的回忆 2020-12-28 21:49

I want to use JMS to connect to IBM MQ. How do i specify the queuemanager, the channel and other properties ?

5条回答
  •  囚心锁ツ
    2020-12-28 22:07

    Using JNDI for connectionFactory/destinations lookups, provide the InitialContext with the following properties:

    java.naming.provider.url=:/
    java.naming.factory.initial=com.ibm.mq.jms.context.WMQInitialContextFactory
    java.naming.security.authentication=none
    java.naming.security.credentials=
    java.naming.security.principal=
    

    using WAS (Websphere Application Server) queues, the properties would be as follows:

    java.naming.provider.url=iiop://:
    java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory
    java.naming.security.authentication=none
    java.naming.security.credentials=
    java.naming.security.principal=
    

    The rest would be as follows:

    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
    

提交回复
热议问题