简体   繁体   中英

Spring Integration with WebSphere JMS IBM MQ provider

We have a WebSphere JMS Queue and QueueConnectionFactory with provider as IBM MQ. we can not connect to IBM MQ directly.

I have the below configuration - I have bean jmsConnectionFactory that creates factory using InitialContext as expected. THE_QUEUE is JNDI name of my queue

<int-jms:inbound-channel-adapter channel="transformedChannel" connection-factory="jmsConnectionFactory" 
destination-name="THE_QUEUE">
<int:poller fixed-delay="500" />
</int-jms:inbound-channel-adapter>

It is failing with error

Caused by: com.ibm.msg.client.jms.DetailedInvalidDestinationException: JMSWMQ2008: Failed to open MQ queue 'THE_QUEUE'. JMS attempted to perform an MQOPEN, but WebSphere MQ reported an error. Use the linked exception to determine the cause of this error. Check that the specified queue and queue manager are defined correctly.

My outbound channel configuration

<int-jms:outbound-channel-adapter id="respTopic" 
connection-factory="jmsConnectionFactory" 
destination-name="THE_REPLYQ" channel="process-channel"/>

If I use java code - it works creating MessageProducer from session.createProducer and send message, create MessageConsumer on queuesession.createConsumer(outQueue); and receive()

Please van you help, on how can I create jms inbound and outbound adapters for these queues using spring integration and process messages

EDIT:

   @Bean
    public ConnectionFactory jmsConnectionFactory(){
        ConnectionFactory connectionFactory = null ;           
        Context ctx = null;         
        Properties p = new Properties();
        p.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
        p.put(Context.PROVIDER_URL, "iiop://hostname.sl");
        p.put("com.ibm.CORBA.ORBInit", "com.ibm.ws.sib.client.ORB");

       try {
            ctx = new InitialContext(p);        
            if (null != ctx)
                System.out.println("Got naming context");
            connectionFactory = (QueueConnectionFactory) ctx.lookup

("BDQCF");
}...


@Bean
public JmsListenerContainerFactory<?> mydbFactory(ConnectionFactory jmsConnectionFactory,
                                                DefaultJmsListenerContainerFactoryConfigurer configurer) {
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    configurer.configure(factory, jmsConnectionFactory);

    return factory;
}

THe code and configuration works for a queue that uses WebSphere default JMS provider

EDIT2 : Code added after comment

<int:channel id="jmsInputChannel" />
  <jee:jndi-lookup id="naarconnectionFactory" jndi-name="MQ_QUEUE" resource-ref="false">
   <jee:environment>
      java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory
      java.naming.provider.url=iiop://host.ws
   </jee:environment>
</jee:jndi-lookup>

<int-jms:inbound-channel-adapter id="jmsIn"  channel="jmsInputChannel" 
connection-factory="jmsNAARConnectionFactory" destination-name="naarconnectionFactory">
   <int:poller fixed-delay="500" />
</int-jms:inbound-channel-adapter>

您不仅可以在那里使用JNDI名称-您必须执行JNDI查找以将其解析为Destination请参阅Spring JMS文档

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM