Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing MQ with JMS

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

like image 345
hakish Avatar asked Sep 09 '10 10:09

hakish


People also ask

Does IBM MQ use JMS?

The JMS specification defines a set of interfaces that applications can use to perform messaging operations. From IBM MQ 8.0, the product supports the JMS 2.0 version of the JMS standard.

How do I access IBM MQ?

The default URL to access the IBM® MQ Console is https://localhost:9443/ibmmq/console . If the HTTP host or port is changed from the default, or if the HTTP port is enabled, you can determine the URL by using the dspmqweb command.

Is JMS same as MQ?

JMS is the specification provided by Sun for messaging. MQ Queue is the IBM's implementation of JMS. Similary JBoss has its own implementation. JMS Queue is the generic term.


2 Answers

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)));
}
like image 93
johnam Avatar answered Oct 30 '22 22:10

johnam


Agree with Johnam, it happened because the ConnectionFactory set as server by default, it need to be set as client, you said that it works on same machine. Because I also met the same situation, it run when on same machine, in this case because your machine is as WMQ Server so do the program, but when you run on different machine then your program must set as client.

I fix it using set some parameter on ConnectionFactory:

<bean id="mqConnectionFactory" class="com.ibm.mq.jms.MQConnectionFactory">
....
<property name="transportType" value="1" />
<property name="clientReconnectTimeout" value="2" /> 
<property name="clientReconnectOptions" value="0" />
</bean>
like image 41
Imam Baihaqi Avatar answered Oct 30 '22 21:10

Imam Baihaqi