ibm-messaging / mq-jms-spring

Components to assist MQ JMS integration with Spring frameworks
Apache License 2.0
189 stars 102 forks source link

Issue with JMS PCF messages #31

Closed JakesIV closed 5 years ago

JakesIV commented 5 years ago

I just want to know if it would be possible to consume MQEvent format (PCF messages) using this API. I did try and keep on getting this error "MQJE001: Completion Code '2', Reason '3013'." which according the big Google is because JMS do not support the additional MQ headers. I have used the method described here to convert the byte message to PCF. https://www.ibm.com/support/knowledgecenter/SSFKSJ_8.0.0/com.ibm.mq.dev.doc/q128400_.htm I saw this discussion but I had conclusion. http://www.mqseries.net/phpBB2/viewtopic.php?t=71804 Could you please help and if you also ask why one want to process PCF message in JMS the answer is simple to process MQ event messages to push to ELK stack

Sample code `@JmsListener(destination = "SYSTEM.ADMIN.QMGR.EVENT") public void onQmgrEventMessage(final BytesMessage message) { try { int bodySize = (int) message.getBodyLength();
byte[] data = new byte[bodySize];
message.readBytes(data);

        // Read into Stream and DataInput Stream    
        ByteArrayInputStream bais = new ByteArrayInputStream(data);    
        DataInput dataInput = new DataInputStream(bais);    

        // Pass to PCF Message to process   
        PCFMessage response = new PCFMessage(dataInput);
        System.out.println(response.getReason());
        //PCFEventProcess.processMessage(pcfResponseMessage);
    } catch (JMSException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (MQDataException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

}`

ibmmqmet commented 5 years ago

See https://www.ibm.com/developerworks/community/blogs/messaging/entry/PCF_Processing_in_JMS_a_gotcha_and_the_solution?lang=en

JakesIV commented 5 years ago

Excellent that worked for me. I will post another issue which I have picked up when reading messages with format MQHRF2 (not sure if the is a spelling error in RFHUTIL, I always thought it was MQRFH2 header). This one fails way before it gets to my code.