1
votes

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>
1

1 Answers

1
votes

You can't just use the JNDI name there - you must perform a JNDI lookup to resolve it to a Destination - see the Spring JMS Documentation.