Author |
Message
|
simran |
Posted: Tue Mar 22, 2005 8:51 am Post subject: problem with setting RFH2 header in java |
|
|
Newbie
Joined: 20 Mar 2005 Posts: 8
|
I have the following code snippet to set RFh2 header in java.
However, when I view the message in MQ visual browse, its is not being deciphered as RFH2 header. What am i missing?
Also, I counted the bytes and it should be 36 bytes in RFH2 I am setting, but when I do the length of the message - it displays that the length is 60.
The message has nothing but RFH2 structure.
Any help is appreciated.
--------------------------------------------------------------------------------
qMgr = new MQQueueManager(qManager);
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF |
MQC.MQOO_OUTPUT ;
MQQueue test_queue = qMgr.accessQueue("Q_ECM_TEST_CHAT",openOptions);
MQMessage test = new MQMessage();
test.writeString("RFH "); // String rfhStrucID
test.writeLong(2); //version
test.writeLong(36); //rfhStrucLength
test.writeLong(273); //encoding
test.writeLong(819); //codedCharacterSetID
test.writeString("MQSTR "); //rfhFormat
test.writeLong(0); //rfhFlags
test.writeLong(1208); //rfhNameValueCCSID
int len = test.getMessageLength();
System.out.println("len of msg = " + len);
MQPutMessageOptions pmo = new MQPutMessageOptions();
test_queue.put(test, pmo);
test_queue.close();
qMgr.disconnect(); |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Mar 22, 2005 8:57 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You need to set the Format of the message to indicate that it's an MQRFH2 format. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
simran |
Posted: Tue Mar 22, 2005 9:08 am Post subject: |
|
|
Newbie
Joined: 20 Mar 2005 Posts: 8
|
Hi Jeff:
I thought by sending the RFH2 structure in the beginning of the message, it understands that.
How do I set the format?
The pre-defined values for the variable MQMessage.format
do not have anything that specifies RFH2.
I appreciate your help.. As you can tell, I am newbie.
Thanks,
simran |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Mar 22, 2005 9:19 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
simran |
Posted: Tue Mar 22, 2005 9:34 am Post subject: |
|
|
Newbie
Joined: 20 Mar 2005 Posts: 8
|
Jeff:
I added the following line
test.format=MQC.MQFMT_RF_HEADER_2;
and the following before setting the payload
test.encoding=273;
test.characterSet=819;
These are the same values I specified in RFH2 structure.
WHen I view the message, I get an error with reason code 2119
MQRC_NOT_CONVERTED
Thanks for your help,
Naga |
|
Back to top |
|
 |
malammik |
Posted: Tue Mar 22, 2005 10:12 am Post subject: |
|
|
 Partisan
Joined: 27 Jan 2005 Posts: 397 Location: Philadelphia, PA
|
|
Back to top |
|
 |
simran |
Posted: Tue Mar 22, 2005 10:34 am Post subject: |
|
|
Newbie
Joined: 20 Mar 2005 Posts: 8
|
I do have the message length divisible by 4.
However, I have an empty message with nothing but RFh2 structure and
I expect the length to be 36.
Th elength of the message turns out to be 60.
I am unable to figure out where the other 24 bytes are?
Is it the attributes I set for the message (encoding, format etc?) |
|
Back to top |
|
 |
malammik |
Posted: Tue Mar 22, 2005 10:44 am Post subject: |
|
|
 Partisan
Joined: 27 Jan 2005 Posts: 397 Location: Philadelphia, PA
|
|
Back to top |
|
 |
malammik |
Posted: Tue Mar 22, 2005 10:47 am Post subject: |
|
|
 Partisan
Joined: 27 Jan 2005 Posts: 397 Location: Philadelphia, PA
|
God bless 2gb email accounts.
public MQMessage buildRFH2Header(MQMessage msg) throws IOException {
String pubCommand = new String();
pubCommand = "<psc><Command>Publish</Command><Topic>Stock</Topic>" +
"<QMgrName>QFLEXT1</QMgrName><QName>QFLEXT1.A</QName></psc>";
int folderLength = pubCommand.length();
MQMessage theMsg = msg;
theMsg.format = MQC.MQFMT_RF_HEADER_2; // Msg Format
theMsg.writeString(MQC.MQRFH_STRUC_ID); // StrucId
theMsg.writeInt4(MQC.MQRFH_VERSION_2); // Version
theMsg.writeInt4(MQC.MQRFH_STRUC_LENGTH_FIXED_2 + folderLength + 4);
//4) + rf); // StrucLength
theMsg.writeInt4(MQC.MQENC_NATIVE); // Encoding
theMsg.writeInt4(MQC.MQCCSI_DEFAULT); // CodedCharacterSetId
theMsg.writeString(MQC.MQFMT_NONE); // Format (content)
theMsg.writeInt4(MQC.MQRFH_NO_FLAGS); // Flags
theMsg.writeInt4(1208); // NameValueCCSID = UTF-8
theMsg.writeInt4(folderLength);
theMsg.writeString(pubCommand);
theMsg.writeString("begin payload");
return theMsg;
} _________________ Mikhail Malamud
http://www.netflexity.com
http://groups.google.com/group/qflex |
|
Back to top |
|
 |
simran |
Posted: Tue Mar 22, 2005 10:49 am Post subject: |
|
|
Newbie
Joined: 20 Mar 2005 Posts: 8
|
Mikhail:
I would so very much appreciate this..
I am trying it right now..
Thanks very very much. |
|
Back to top |
|
 |
simran |
Posted: Tue Mar 22, 2005 12:07 pm Post subject: |
|
|
Newbie
Joined: 20 Mar 2005 Posts: 8
|
Mikhail:
The code works great for me..
I have seen multiple posts asking for an example in java to create RFH2.
You should submit this as a sample.
Thanks again,
simran |
|
Back to top |
|
 |
tricky_knight |
Posted: Tue Mar 22, 2005 1:45 pm Post subject: |
|
|
Apprentice
Joined: 12 Mar 2005 Posts: 34
|
cool code snippet, thanks alot. I agree it should be in the repository for as many questions get asked about setting RFH2's in Java.
One question, I noticed that you used the pub folder. How would you have added multiple folder ie <usr> and <jms>
I tried out the snippet and although it worked perfect with one rfh2 folder of choice, trying to add more than one is not recognized by rfhutil only the first folder set.
thanks |
|
Back to top |
|
 |
simran |
Posted: Tue Mar 22, 2005 2:14 pm Post subject: |
|
|
Newbie
Joined: 20 Mar 2005 Posts: 8
|
I just got it to work..
Basically, after the std RFH structure,
you would insert mcd Length and mcdstructure
then insert jms length and jms structure
then insert usr length and usr structure..
The structure length gets increased as you keep adding folders..
Make sure you increase that as well and add by additional 4 for length for each folder. |
|
Back to top |
|
 |
tricky_knight |
Posted: Tue Mar 22, 2005 3:00 pm Post subject: |
|
|
Apprentice
Joined: 12 Mar 2005 Posts: 34
|
hey man, thanks for the info
And many thanks to Mikhail - I too got it working now.
By using the JAVA MANUAL with this it is pretty nice.
thanks again
ps. the only thing I would like to understand more is the part about padding the length to be divisible by 4. why is this?
this doesnt seem like the most effiicent way but until I totally understand..
Code: |
theMsg.writeInt4(MQC.MQRFH_STRUC_LENGTH_FIXED_2 + jmsfolderLength + 4 + usrfolderLength + 4 + mcdfolderLength + 4); |
|
|
Back to top |
|
 |
malammik |
Posted: Tue Mar 22, 2005 4:06 pm Post subject: |
|
|
 Partisan
Joined: 27 Jan 2005 Posts: 397 Location: Philadelphia, PA
|
|
Back to top |
|
 |
|