Guenevere
Guenevere

Reputation: 75

Converting JMS Message to IBM PCF

I am in a bit of a bind. I am trying to read a message of a WMQ via jms and then convert it to a pcf message for processing. I have only been able to find one resource on this and it hasn't been very helpful [bottom of http://www-01.ibm.com/support/docview.wss?uid=swg21395682 ]

I have tried to implement the technique in the above doc but every time I get to line

PCFMessage response = new PCFMessage(dataInput);

I throw MQRC 3013 - MQRCCF_STRUCTURE_TYPE_ERROR

This is the way my code looks, maybe you can see something I don't.

BytesMessage message = null;
    do {
        // The consumer will wait 10 seconds (10,000 milliseconds)
        message = (BytesMessage) myConsumer.receive(10000);

        // get the size of the bytes message & read into an array
        int bodySize = (int) message.getBodyLength();
        byte[] data = new byte[bodySize];
        message.readBytes(data, bodySize);

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

        // Pass to PCF Message to process
        //MQException.logExclude(new Integer(2079));
        PCFMessage qStatsPcf = new PCFMessage(dataInput);

        session.commit();
        if (message != null) {
            processMessage(qStatsPcf);
        }
    } while (message != null);
    myConsumer.close();

A couple updates in response to T.Rob's answer. I am currently running MQ 7.0. This is a what it is type thing, I can't currently upgrade.

As to what I am trying to do, I am pulling messages from SYSTEM.ADMIN.STATISTICS.QUEUE and I want to parse that information for auditing purposes. The reasoning behind converting to a PCF message is that I am looking to pull some PCF parameters from these messages - for example .getParameter(PCFConstants.MQIAMO_PUTS)

I am not attempting to send messages to MQ in anyway, just pull messages off and process them.

Upvotes: 2

Views: 777

Answers (2)

Umapathy
Umapathy

Reputation: 772

my 2 cents...

Why are you using JMS to retrieve PCF Messages?
MQ Java is best placed to handle all statistics and event message. My suggestion is go with MQQueueManager object and retrieve a MQMessage out of SYSTEM.ADMIN.STATISTICS.QUEUE and pass it to PCFMessage constructor. I have not compiled or tested the following, but it gives an outline.

//no try catch block to keep it simple
//assumed MQQueueManager (qmgr object) is already created
//assumed statQueue is available through qmgr.accessQueue() method
do {
    MQMessage message = new MQMessage();
    //gmo as CMQC.MQGMO_FAIL_IF_QUIESCING | CMQC.MQGMO_WAIT | CMQC.MQGMO_SYNCPOINT | CMQC.MQGMO_CONVERT;
    message = statQueue.get(message, gmo);

    // Pass to PCF Message to process
    PCFMessage qStatsPcf = new PCFMessage(message);

    qmgr.commit();
    if (message != null) {
        processMessage(qStatsPcf);
    }
} while (message != null);

statQueue.close();
qmgr.close();

Upvotes: 1

T.Rob
T.Rob

Reputation: 31832

A couple problems with this question:

  • There is no mention of the version of the version of MQ jms client that is in use. Since IBM has repackaged the Java/JMS classes several times, it is necessary to mention which version you are working with to get a better answer.
  • It is unclear what it is you are trying to do. An MQ PCF message is processed by the MQ Command Server. The messages are a binary format consisting of a linked list of name/type/value tuples. If your message body is not already in PCF name/type/value format, then casting it as a PCF message is expected to fail.

Since it is not possible to respond to the question as worded with a solution, I'll provide some recommendations based on wild guesses as to what it is you might be trying to do.

  1. Use a modern MQ client. The Technote you linked to is for out-of-support versions of MQ client. You want one that is at least MQ v7.1, but preferably v8.0. since any version of MQ client works with any version of MQ, use the version that is most current. Just remember, the functionality you get is based on the oldest version of MQ used at the client or server. A v8.0 client doesn't get you v8.0 function on a v7.0 QMgr. Go to the SupportPacs page and look for entries with names like MQC**. The MQ v8.0 client is current and it is SupportPac MQC8.
  2. If you really are trying to submit PCF messages to MQ's command processor, instantiate a PCF Agent to do it. Then construct the PCF message using one of the PCF message constructors that lets you specify the selectors and their values.
  3. What happened when you tried using the PCF Java samples? Did they also fail? Did they work? If so, how does your code differ? You did look at IBM's PCF samples, right? Please see Installation directories for samples for the location for the sample programs, including the PCF samples.
  4. If you are not attempting to send messages to the MQ Command Processor, please update the question to let us know what it is you are trying to do and why you believe you need PCF messages to do it.

Upvotes: 4

Related Questions