Support Questions

Find answers, ask questions, and share your expertise

How to access MQQueue level properties on behalf of a PublishJMS connection

avatar
Expert Contributor

I’m seeing an issue where the output sent to the IBM MQ (ESB) from our NiFi configuration sends a format (MQHRF2) not recognized by the ESB consumer. This is very similar to the forum issue posted here: http://forum.spring.io/forum/spring-projects/integration/jms/31307-invalid-message-received-in-remot...

Unfortuntately I don't have the capability to get this correctly configured from the MQ Administration side. There doesn't appear to be a property to control this from the connection factory settings for the "com.ibm.mq,jms.MQQueueConnectionFactory" that I can find. However, it appears the "com.ibm.mq.jms.MQQueue" counterpart will provide this capability via the "targetClient" with value "1".

So I'm hoping to be able to instantiate the MQQueue with a property or similar w/in PublishJMS or via an context parameter similar to the behavior of "SS Context Service" I believe. Any light you can shed on this would be greatly appreciated.

1 ACCEPTED SOLUTION

avatar
Master Guru

Maybe make this your topic, try:

myQueue?targetClient=1

You could also write your own processor.

https://community.hortonworks.com/content/kbentry/73355/adding-a-custom-processor-to-nifi-linkproces...

View solution in original post

4 REPLIES 4

avatar
Master Guru

Maybe make this your topic, try:

myQueue?targetClient=1

You could also write your own processor.

https://community.hortonworks.com/content/kbentry/73355/adding-a-custom-processor-to-nifi-linkproces...

avatar
Expert Contributor

Thank you for the quick response. I'm needing to go the roll my own route, since the I get an error that "targetClient" is not allowed for 'XMSC_DESTINATION_NAME'.

When setting up a processor that uses custom java code what script engine to you specify assuming you are using on of the script processors? Also, to you know how to inject the flowfile stream contents into the java code, since I need that instead of the line ""Hello MQSTR world via MQQueue"?

import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import com.ibm.mq.jms.MQQueue;
import com.ibm.mq.jms.MQQueueConnectionFactory;
import com.ibm.msg.client.wmq.compat.jms.internal.JMSC;
public void testMqstrViaApiTextMessage() throws Exception {
    QueueConnectionFactory connectionFactory = new MQQueueConnectionFactory();
    ((MQQueueConnectionFactory) connectionFactory).setHostName("mfdevlcics.mayo.edu");
    ((MQQueueConnectionFactory) connectionFactory).setPort(3667);
    ((MQQueueConnectionFactory) connectionFactory).setChannel("MCF.EDT.Q10I.01");
    ((MQQueueConnectionFactory) connectionFactory).setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
    QueueConnection connection = connectionFactory.createQueueConnection();
    connection.start();
    QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue queue = session.createQueue("IMA.EDT.NL.007");
    // Force MQSTR format
    ((MQQueue) queue).setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ);
    QueueSender messageProducer = session.createSender(queue);
    TextMessage textMessage = session.createTextMessage("Hello MQSTR world via MQQueue");
    messageProducer.send(textMessage);
        session.close();
    connection.close();
}

avatar
Expert Contributor

I see getting customized processors is a bit more involved as described here: https://community.hortonworks.com/articles/4318/build-custom-nifi-processor.html

avatar
New Contributor

In destinationName put this

queue:///myQueue?targetClient=1

That works for me.