Accessing MQ with JMS

hakish picture hakish · Sep 9, 2010 · Viewed 28.4k times · Source

i am using MQ7 and trying to access a queue with JMS api's. Getting this error. Has anyone seen it before? How do i resolve this? TIA

Exception in thread "main" com.ibm.msg.client.jms.DetailedJMSException: JMSFMQ6312: An exception occurred in the Java(tm) MQI. The Java(tm) MQI has thrown an exception describing the problem. See the linked exception for further information.

Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2495;AMQ8568: The native JNI library 'mqjbnd' was not found. [3=mqjbnd]

Caused by: java.lang.UnsatisfiedLinkError: no mqjbnd in java.library.path

Answer

johnam picture johnam · Jan 7, 2015

Probably a bit late but I had the same problem and found that this can be avoided if you use a different Connection Mode when connecting to a remote Queue. By default the MQConnectionFactory uses WMQ_CM_BINDINGS as it's connection mode. If you change it to WMQ_CM_CLIENT (or whichever connection mode you like that doesn't require native libraries) you should be fine.

@Test
public void testMQConnectionMode() throws JMSException {
    MQConnectionFactory cf = new MQConnectionFactory();
    assertThat(cf.getIntProperty(CommonConstants.WMQ_CONNECTION_MODE), is(equalTo(CommonConstants.WMQ_CM_BINDINGS)));
    cf.setIntProperty(CommonConstants.WMQ_CONNECTION_MODE, CommonConstants.WMQ_CM_CLIENT);
    assertThat(cf.getIntProperty(CommonConstants.WMQ_CONNECTION_MODE), is(equalTo(CommonConstants.WMQ_CM_CLIENT)));
}