Mule ESB: Setup JMS Endpoint for WMQ Queue

一曲冷凌霜 提交于 2019-12-04 10:44:42

Just solved the problem:

It is right that we need to create a java class to set the targetClient. And to do so, we can follow the link that I gave above. However, we will need to change the code a bit. Here is the right code:

import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Session;

import org.mule.api.endpoint.ImmutableEndpoint;
import org.mule.transport.jms.Jms11Support;
import org.mule.transport.jms.JmsConnector;

import com.ibm.mq.jms.JMSC;
import com.ibm.mq.jms.MQQueue;

/**
* Implements WebSphere MQ specific JMS support for Mule. The class
* overrides the createDestination method to intercept JMS Queue object
* creation and sets the targetClient=1 property on created MQQueue
* objects. This is necessary to prevent non-JMS consumers from being
* choked by RFH2 headers.
*/
public class CustomJms11Support extends Jms11Support {

    public CustomJms11Support(JmsConnector connector) {
        super(connector);
    }

    @Override
    public Destination createDestination(Session session, String name, boolean
    topic, ImmutableEndpoint ie) throws JMSException {
        Destination destination = super.createDestination(session, name, topic, ie);
        if (destination instanceof MQQueue){
            ((MQQueue) destination).setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ);
        }
        return destination;
    }
}

And then, we will need to set a property called "JMS_IBM_Character_Set" (If not we will get "Expected MQ message characterSet '819', but received '1208'" error) before send the request to JMS endpoint. Here is how I configure it:

<set-property propertyName="JMS_IBM_Character_Set" value="ISO8859_1" doc:name="Property"/>

And just for your information, by changing the WMQ endpoint to JMS endpoint, for sure it improve the performance.

Hopefully it would be useful :D

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!