1

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>
JoshMc
  • 10,239
  • 2
  • 19
  • 38
Kris Swat
  • 788
  • 1
  • 10
  • 39

1 Answers1

0

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.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • Hi Gary, I dont think there is an issue with JNDI lookup. My bean is doing - Properties(), INITIAL CONTEXT FACTORY, PROVIDER URL ORBInit and looking up for queueconnectionfactory via lookup. I also have a bean that creates JmsListenerContainerFactory. Is that ok? – Kris Swat May 03 '18 at 08:30
  • You misunderstood me; you can't use a JNDI name here `destination-name="THE_QUEUE"` - you must do a JNDI lookup to get the destination and then use `destination-="queueFromJNDILookup"`. Or configure the destination as a `` without using JNDI. – Gary Russell May 03 '18 at 12:56
  • Please see EDIT2: Getting error Caused by: com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2035' ('MQRC_NOT_AUTHORIZED'). at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:204) – Kris Swat May 07 '18 at 14:54
  • @KrisSwat Gary's answer has solved your initial problem. The 2035 indicates that the queue manager is rejecting the request because of a permission issue of some sort, there could be many causes. I suggest you accept Gary's answer to your initial problem. Search on Stack overflow and Google for the 2035 error (there are many questions on here already dealing with that). If you can't find the cause then open a new question related to the 2035 issue. – JoshMc May 07 '18 at 15:26