Topic
  • 3 replies
  • Latest Post - ‏2007-11-22T00:09:37Z by SystemAdmin
SystemAdmin
SystemAdmin
308 Posts

Pinned topic MQ triggering problem under TXSeries with Java

‏2007-11-09T22:58:10Z |
I am trying to get WebSphere MQ triggering to work with TXSeries under a CICS region, with a Java program being triggered. The problem is retrieving the MQ trigger message when the Java trx gets started; this fails.

My setup:
Win2003 R2 Std
TXSeries 6.1 PTF2
IBM JDK 1.5
WMQ 6.0.1

The MQ queue + process definition + trigger monitor (amqltmc4) setup works Ok.
On putting a msg on the configured queue, the CICS trx that is set in the MQ process definition gets kicked off just fine.

When starting a trx with a program written in COBOL, the retrieve reads the MQTMC2 trigger message structure correctly, with the MQ Qmgr, Queue etc. info.
When switching to a Java program, I do NOT get the MQTMC2 trigger message (assuming I do the right thing).

This is the Java class source:

import java.util.*;
import com.ibm.cics.server.*;
import com.ibm.mq.*;

public class CicsTest01 {

public static void main(CommAreaHolder CAH)
throws Throwable {

try {

Task task = Task.getTask();

if (task != null) {

task.out.println("CommAreaHolder.value="+ CAH.value.toString());
task.out.println("Task.StartCode="+ task.getSTARTCODE());
task.out.println("Task.TransactionName="+ task.getTransactionName());
task.out.println("Task.TaskNumber="+ task.getTaskNumber() );
//task.out.println("Task.ProgramName="+ task.getProgramName());
//task.out.println("Task.UserID="+ task.getUSERID());
task.out.println("Task.FCI="+ task.getFCI());

BitSet retrvFlags = null;
RetrievedDataHolder rdhl = null;

BitSet retrieveFlags = new BitSet(RetrieveBits.NUMBER_OF_BITS);
retrieveFlags.set(RetrieveBits.DATA);
RetrievedDataHolder retrieveData = new RetrievedDataHolder();

task.retrieve(retrieveFlags, retrieveData);

if (retrieveData != null) {
task.out.println("RetrievedataHolder.value.data=" + retrieveData.value.data.toString());
}
else System.err.println("Failed to get Task retrieved data");

Object obj = task.getPrincipalFacility();

if (obj != null) {
if (obj instanceof TerminalPrincipalFacility)
task.out.println("Task.getPrincipalFacility()=TerminalPrincipalFacility");
if (obj instanceof ConversationPrincipalFacility)
task.out.println("Task.getPrincipalFacility()=ConversationPrincipalFacility");
}
else
task.out.println("Task.getPrincipalFacility()=no PrincipalFacility");

}
else System.err.println("Failed to get Task instance");

}
catch(Throwable T) {
System.err.println("Caught unexpected Throwable (" + T + ")");
throw T;
}
}
}
Below the output in the console log file as a result of above program being triggered:

CommAreaHolder.value=[B@b720b72
Task.StartCode=SD
Task.TransactionName=TS01
Task.TaskNumber=9
Task.FCI=0
RetrievedataHolder.value.data=[B@3e243e24 <= here I expected to see the MQTMC2 trigger msg string
Task.getPrincipalFacility()=no PrincipalFacility
Question: the retrieved byte array is NOT the MQ trigger message data (MQTMC2 structure).
Do I need to perform some translation on the byte array to obtain a readable result?
Anyway, even if processing is necessary, the length of the byte array is nowhere close to the length of the MQTMC2 structure.
Anyone who can tell me what is wrong here, or what I am doing wrong?

Note 1: Task.StartCode() results in value 'SD', which indicates a trx start with data.
Task.FCI() results in value 0 (=FCI_START_NO_DATA). So for me the FCI value contradicts the StartCode value.
Is this a bug, or am I missing something?

Note 2: I had to comment out the method calls Task.getProgramName() and Task.getUSERID(), otherwise at runtime the program crashes big time. Weird!

Bas.
Updated on 2007-11-22T00:09:37Z at 2007-11-22T00:09:37Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    308 Posts

    Re: MQ triggering problem under TXSeries with Java

    ‏2007-11-12T07:10:32Z  
    Hi Bas,

    I am not a Java pro, but from what I see you are getting an address of the
    DataHolder ([B@3e243e24) printed - maybe that is the address of the String
    buffer, and am not pretty sure if the toString() function is working or is the
    correct usage - as there may be termination characters in the buffer. It might
    be worth trying to decipher and print individual byte values in a loop like
    RetrievedataHolder.value.data.value[1], RetrievedataHolder.value.data[2] and
    so on. You could also try the new String(RetrievedataHolder.value.data.value).

    I don't suspect any other problems with your program - they seem perfect!.

    As with why FCI is returning START_WITH_NO_DATA (value 0), and your program
    crashes when issuing the get, I do think it might be a bug and it would be nice
    if you could open a PMR - report to IBM!.

    Cheers,
    Hari
  • SystemAdmin
    SystemAdmin
    308 Posts

    Re: MQ triggering problem under TXSeries with Java

    ‏2007-11-12T07:48:50Z  
    Hi Bas,

    I found the following snippet (Example 6-22) in a redbook called
    "Java Application Development for CICS" located at
    http://www.redbooks.ibm.com/redbooks/pdfs/sg245275.pdf .

    Task.getTask().retrieve(whatToRetrieve, rdh);
    System.out.println("Retrieved DATA: " + new String(rdh.value.data)); // (2)
    System.out.println("Retrieved QUEUE: " + new String(rdh.value.queue)); // (3)

    HTH.

    Cheers,
    Hari
  • SystemAdmin
    SystemAdmin
    308 Posts

    Re: MQ triggering problem under TXSeries with Java

    ‏2007-11-22T00:09:37Z  
    Thanks Hari,

    Yes, you were right, the toString() method gives you the address of the byte array,
    what is normally the case with arrays, I should have remembered that.
    Passing the byte array to the constructor of a new string worked just fine.

    So this is what worked:
    BitSet retrieveFlags = new BitSet(RetrieveBits.NUMBER_OF_BITS);
    retrieveFlags.set(RetrieveBits.DATA);
    RetrievedDataHolder retrieveData = new RetrievedDataHolder();
    task.retrieve(retrieveFlags, retrieveData);
    String trigMsg = new String(retrieveData.value.data);
    I looked around to see if I can submit a PMR report, but didn't find how, or I just cannot as I don't have an IBM client id.

    Bas