Format is a message descriptor attribute. Messages of a particular Format conform to a specific structure which depends on Format type. For example, CICS, IMS, MQRFH2 and so on. The structure for each built-in MQSeries Format is different and is defined by MQSeries. For more information on MQSeries Formats, see the online MQSeries documentation at the following URL:
Using MQSeries control you can send messages that correspond to both built-in MQSeries formats as well as user-defined formats. This is possible only by using the putMessageAsBytes function.
To send a message that conforms to an MQSeries Format, you need to write Java code in the process JPD file, as shown in the following examples.
Example: Sending a message that conforms to the CICS Format (using the putMessage function)
public com.bea.wli.control.mqmdHeaders.MQMDHeadersDocument putin;
This variable represents the input MQMDHeaders document XMLBean variable for the putMessage function.
public void perform() throws Exception { putin.getMQMDHeaders().setFormat(MQC.MQFMT_CICS); bytmsg = getCICSHeader(); } public byte[] getCICSHeader() throws Exception { ByteArrayOutputStream bstream = new ByteArrayOutputStream(); DataOutputStream ostream = new DataOutputStream (bstream); ostream.writeChars("CIH "); // Struct id
ostream.writeInt(1); // Version ostream.writeInt(164); // StrucLength ostream.writeInt(273); // Encoding ostream.writeInt(819); // CodedCharSetId ostream.writeChars(" "); // Format ostream.writeInt(0); //Flags ostream.writeInt(0); //ReturnCode ostream.writeInt(0); //CompCode ostream.writeInt(0); //Reason ostream.writeInt(273); //UOWControl ostream.writeInt(-2); //GetWaitInterval ostream.writeInt(1); //LinkType ostream.writeInt(-1); //OutputDataLength ostream.writeInt(0); //FacilityKeepTime ostream.writeInt(0); //ADSDescriptor ostream.writeInt(0); //ConversationalTask ostream.writeInt(0); //TaskEndStatus ostream.writeBytes("\0\0\0\0\0\0\0\0"); //Facility ostream.writeChars(" "); //Function ostream.writeChars(" "); //AbendCode ostream.writeChars(" "); //Authenticator ostream.writeChars(" "); //Reserved1 ostream.writeChars(" "); //ReplyToFormat ostream.writeChars(" "); //RemoteSysId ostream.writeChars(" "); //RemoteTransId ostream.writeChars(" "); //TransactionId ostream.writeChars(" "); //FacilityLike ostream.writeChars(" "); //AttentionId ostream.writeChars(" "); //StartCode ostream.writeChars(" "); //CancelCode ostream.writeChars(" "); //NextTransactionId ostream.writeChars(" "); //Reserved2 ostream.writeChars(" "); //Reserved3 ostream.writeChars("HelloWorld"); ostream.flush(); byte[] bArr = bstream.toByteArray(); return bArr; }
These lines of code set the Format element in the input MQMD Headers document of the putMessage function, to MQC.MQFMT_CICS represented by the String "MQCICS ".
The getCICSHeader function writes the fields present in the CICS header structure to a byte array output stream and returns an array of bytes. The values of the fields that have been given in this example can be modified as required. The actual message can be appended to this byte array at the end and can be Put into the MQSeries queue. This byte array can be provided as the first parameter to the putMessageAsBytes function which is added to the process JPD file, after the Perform node. For more information on the putMessage function, see Sending and Receiving Messages.
Example: Sending a message that conforms to the IMS Format (using the putMessage function)
public com.bea.wli.control.mqmdHeaders.MQMDHeadersDocument putin;
This variable represents the input MQMDHeaders document XMLBean variable for the putMessage function.
public void perform() throws Exception { putin.getMQMDHeaders().setFormat(MQC.MQFMT_IMS); bytmsg = getIMSHeader(); } public byte[] getIMSHeader() throws Exception { ByteArrayOutputStream bstream = new ByteArrayOutputStream(); DataOutputStream ostream = new DataOutputStream (bstream);
ostream.writeBytes("IIH "); // Struct id ostream.writeInt(1); // Version ostream.writeInt(84); // Length ostream.writeInt(0); // Encoding ostream.writeInt(0); // CodedCharacterSet ostream.writeBytes(" "); // Format (8 characters) ostream.writeInt(0); // Flags ostream.writeBytes(" "); // LTermOverride ostream.writeBytes(" "); // MFSMapName ostream.writeBytes(" "); // ReplyToFormat ostream.writeBytes(" "); // Authenticator ostream.writeBytes("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); // TransInstanceId ostream.writeBytes(" "); //Transtate ostream.writeBytes("1"); // CommitMode ostream.writeBytes("F"); // Security Scope ostream.writeBytes(" "); // Resrved ostream.writeChars("HelloWorld"); ostream.flush(); byte[] bArr = bstream.toByteArray(); return bArr; }
These lines of code set the Format element in the input MQMD Headers document of the putMessage function, to MQC.MQFMT_IMS represented by the String "MQIMS ".
The getIMSHeader function writes the fields present in the IMS header structure to a byte array output stream and returns an array of bytes. The values of the fields that have been given in this example can be modified as required. The actual message can be appended to this byte array at the end and can be Put into the MQSeries queue. This byte array can be provided as the first parameter to the putMessageAsBytes function which is added to the process JPD file, after the Perform node. For more information on the putMessage function, see Sending and Receiving Messages.
Example: Sending a message that conforms to the MQRFH2 Format (using the putMessage function)
public com.bea.wli.control.mqmdHeaders.MQMDHeadersDocument putin;
This variable represents the input MQMDHeaders document XMLBean variable for the putMessage function.
public void perform() throws Exception { putin.getMQMDHeaders().setFormat(MQC.MQFMT_RF_HEADER_2); bytmsg = getMQRFH2Header(); } public byte[] getMQRFH2Header() throws Exception { ByteArrayOutputStream bstream = new ByteArrayOutputStream(); DataOutputStream ostream = new DataOutputStream (bstream); String strVariableData = "<mcd><Msd>jms_text</Msd></mcd><jms><Dst>someplace</Dst></jms>"; int iStrucLength = MQC.MQRFH_STRUC_LENGTH_FIXED_2 + strVariableData.getBytes().length; while(iStrucLength % 4 != 0) { strVariableData = strVariableData + " "; iStrucLength = MQC.MQRFH_STRUC_LENGTH_FIXED_2 + strVariableData.getBytes().length; } ostream.writeChars(MQC.MQRFH_STRUC_ID);//StrucID ostream.writeInt(MQC.MQRFH_VERSION_2);//Version ostream.writeInt(iStrucLength );//StrucLength ostream.writeInt(273);//Encoding ostream.writeInt(1208);//CodedCharSetID ostream.writeChars(MQSTR);//Format ostream.writeInt(MQC.MQRFH_NO_FLAGS);//Flags ostream.writeInt(1208);//NameValueCCSID ostream.writeInt(strVariableData.getBytes().length);//NameValueLength ostream.writeChars(strVariableData ); //NameValueData ostream.writeChars("HelloWorld"); ostream.flush(); byte[] bArr = bstream.toByteArray(); return bArr; }
These lines of code set the Format element in the input MQMD Headers document of the putMessage function, to MQC.MQFMT_RF_HEADER_2 represented by the String "MQHRF2 ".
The getMQRFH2Header function writes the fields present in the MQRFH2 header structure to a byte array output stream and returns an array of bytes. The values of the fields that have been given in this example can be modified as required. The actual message can be appended to this byte array at the end and can be Put into the MQSeries queue. This byte array can be provided as the first parameter to the putMessageAsBytes function which is added to the process JPD file, after the Perform node. For more information on the putMessage function, see Sending and Receiving Messages.
![]() |
![]() |