ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » problem with setting RFH2 header in java

Post new topic  Reply to topic Goto page 1, 2  Next
 problem with setting RFH2 header in java « View previous topic :: View next topic » 
Author Message
simran
PostPosted: Tue Mar 22, 2005 8:51 am    Post subject: problem with setting RFH2 header in java Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Tue Mar 22, 2005 8:57 am    Post subject: Reply with quote

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
View user's profile Send private message
simran
PostPosted: Tue Mar 22, 2005 9:08 am    Post subject: Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Tue Mar 22, 2005 9:19 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

http://publibfp.boulder.ibm.com/epubs/html/csqzak09/csqzak091k.htm#Header_272

The list in the Using Java manual is not complete. Notice that the difference between what's listed in Using Java, and similar entries in the above are that the Using Java listings put "MQC." at the front of the symbolic name...
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
simran
PostPosted: Tue Mar 22, 2005 9:34 am    Post subject: Reply with quote

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
View user's profile Send private message
malammik
PostPosted: Tue Mar 22, 2005 10:12 am    Post subject: Reply with quote

Partisan

Joined: 27 Jan 2005
Posts: 397
Location: Philadelphia, PA

You need to pad your message lengh to be divisible by 4, otherwise conversion might fail.
_________________
Mikhail Malamud
http://www.netflexity.com
http://groups.google.com/group/qflex
Back to top
View user's profile Send private message Visit poster's website AIM Address
simran
PostPosted: Tue Mar 22, 2005 10:34 am    Post subject: Reply with quote

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
View user's profile Send private message
malammik
PostPosted: Tue Mar 22, 2005 10:44 am    Post subject: Reply with quote

Partisan

Joined: 27 Jan 2005
Posts: 397
Location: Philadelphia, PA

If it is not urgent for you, at home I have a java program that generates an RFH2 header successfully. I will post it tonight.
_________________
Mikhail Malamud
http://www.netflexity.com
http://groups.google.com/group/qflex
Back to top
View user's profile Send private message Visit poster's website AIM Address
malammik
PostPosted: Tue Mar 22, 2005 10:47 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
simran
PostPosted: Tue Mar 22, 2005 10:49 am    Post subject: Reply with quote

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
View user's profile Send private message
simran
PostPosted: Tue Mar 22, 2005 12:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
tricky_knight
PostPosted: Tue Mar 22, 2005 1:45 pm    Post subject: Reply with quote

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
View user's profile Send private message
simran
PostPosted: Tue Mar 22, 2005 2:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
tricky_knight
PostPosted: Tue Mar 22, 2005 3:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
malammik
PostPosted: Tue Mar 22, 2005 4:06 pm    Post subject: Reply with quote

Partisan

Joined: 27 Jan 2005
Posts: 397
Location: Philadelphia, PA

I am not 100% sure why it has to be 4 but it is necessary for the conversion to work. I guess there is something in the "convertor" that requires it.
_________________
Mikhail Malamud
http://www.netflexity.com
http://groups.google.com/group/qflex
Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » IBM MQ Java / JMS » problem with setting RFH2 header in java
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.