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 » Adding MQRFH2 using MQHeaderList, getting MQRC_RFH_ERROR

Post new topic  Reply to topic
 Adding MQRFH2 using MQHeaderList, getting MQRC_RFH_ERROR « View previous topic :: View next topic » 
Author Message
notoneword
PostPosted: Sun May 22, 2011 12:27 pm    Post subject: Adding MQRFH2 using MQHeaderList, getting MQRC_RFH_ERROR Reply with quote

Apprentice

Joined: 17 May 2011
Posts: 37

I'm having some issues writing an MQRFH2 header to a message.

Code:
String nameValueData = "ABC";
MQMessage inMsg = new MQMessage();
// Message's format is set to "MQRFH2  "
...

MQRFH2 rfh2 = new MQRFH2();
rfh2.setNameValueData(nameValueData);
rfh2.setNameValueCCSID(1208);
rfh2.setFormat(MQConstants.MQFMT_STRING);
rfh2.setEncoding(546);
rfh2.setCodedCharSetId(437);
list.add(rfh2);
list.write(inMsg, 1, 437);  // This returns 44, so the structure was written to the message



When I attempt to put inMsg, I get MQRC_RFH_ERROR.

MQRFH2 of a message currently on a queue:

Quote:
MQCHAR4 StrucId: "RFH "
MQLONG Version: 2 (0x00000002)
MQLONG StrucLength: 44 (0x0000002c)
MQLONG Encoding: 546 (0x00000222)
MQLONG CodedCharSetId: 437 (0x000001b5)
MQCHAR8 Format: "MQSTR "
MQLONG Flags: 0 (0x00000000)
MQLONG NameValueCCSID: 1208 (0x000004b8)
MQBYTE[] NameValueData: 0x0000000441424320


MQRFH2 I"m attempting to add to a message

Quote:
MQCHAR4 StrucId: "RFH "
MQLONG Version: 2 (0x00000002)
MQLONG StrucLength: 44 (0x0000002c)
MQLONG Encoding: 546 (0x00000222)
MQLONG CodedCharSetId: 437 (0x000001b5)
MQCHAR8 Format: "MQSTR "
MQLONG Flags: 0 (0x00000000)
MQLONG NameValueCCSID: 1208 (0x000004b8)
MQBYTE[] NameValueData: 0x0400000041424320



The only difference I can see is the byte order of the nameValueLength (first 4 bytes of NameValueData), which is reversed in the MQRFH2 I'm attempting to put. I've tried setting the encoding of the MQRFH2 to different values, and passing in different encoding values to MQHeaderList.write, but I can't seem to get that value in the right byte order. Anyone have any suggestions on setting the encoding correctly, or ideas what the problem may be?

thanks, Tom
Back to top
View user's profile Send private message
notoneword
PostPosted: Sun May 22, 2011 12:45 pm    Post subject: Reply with quote

Apprentice

Joined: 17 May 2011
Posts: 37

I should mention that the same approach works fine for MQRFH_1 header:

Code:

MQRFH rfh = new MQRFH();                  rfh.setNameValueString(nameValueData);                  rfh.setFormat(MQConstants.MQFMT_STRING);                   list.add(rfh);
System.out.println(rfh);
list.write(inMsg);


This code works....
Back to top
View user's profile Send private message
Vitor
PostPosted: Sun May 22, 2011 12:53 pm    Post subject: Re: Adding MQRFH2 using MQHeaderList, getting MQRC_RFH_ERROR Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

notoneword wrote:
I've tried setting the encoding of the MQRFH2 to different values, and passing in different encoding values to MQHeaderList.write, but I can't seem to get that value in the right byte order.


Is this the same situation you laid out in this near-duplicate post?

notoneword wrote:
Anyone have any suggestions on setting the encoding correctly, or ideas what the problem may be?


Slightly off topic but what are you using an MQRFH (rather than an MQRFH2) for?

Also not directly connected but why are you not using JMS / XMS to build the header for you? What do these libraries not do for you that you need to achieve?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
notoneword
PostPosted: Sun May 22, 2011 1:05 pm    Post subject: Reply with quote

Apprentice

Joined: 17 May 2011
Posts: 37

Near-duplicate is not same as "same" - no, that was an issue converting name value data when getting RFH headers off of a message, this is trying to write an MQRFH2 header to a message about to be put.



The application will have an option to put either RFH/RFH2 headers, but since MQRFH is the one that worked for me, not sure how that matters.

I may end up using the classes you mention, but MQHeaderList is supposed to have this functionality.
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon May 23, 2011 4:12 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

notoneword wrote:
Near-duplicate is not same as "same" - no, that was an issue converting name value data when getting RFH headers off of a message, this is trying to write an MQRFH2 header to a message about to be put.


But the same scenario regarding platform & so forth?

notoneword wrote:
I may end up using the classes you mention, but MQHeaderList is supposed to have this functionality.


Well any regular reader of this forum will tell you I can't speak to Java, but I don't see anything in description of the write method of that class which indicates it does this. Just that it adds the headers you've built to a message, nothing about formatting the headers for you.

The RFH2 (which as the version 2 has significantly more functionality than the RFH & is the one that supports JMS) is a tricky thing. I fear you're reinventing a wheel, so unless you need one with more spokes and/or a shiny rim I'd think carefully.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
notoneword
PostPosted: Mon May 23, 2011 4:40 am    Post subject: Reply with quote

Apprentice

Joined: 17 May 2011
Posts: 37

Yes, same platform, etc. I wasn't so much expecting the MQHeaderList.write call to format the header for me, but was looking for a way/reason that the length bytes ended up that way, and any possibility to swap the byte order.

Thanks for the advice. I'll look into the JMS classes for this.
Back to top
View user's profile Send private message
prasadpav
PostPosted: Fri Jun 07, 2013 4:45 am    Post subject: Reply with quote

Centurion

Joined: 03 Oct 2004
Posts: 142

Hi,
Did anyone found a way to fix this problem? I'm using MQ Base Java (Windows XP, MQ v7.0.1.9) API to put a message on a queue with a "usr" folder in the RFH2 header. I'm using server connection channel to connect to the queue manager. I've fiddled with queue property control attribute to be "ALL, FORCE" but still didn't work and there is no such control property available on the server connection channels.
I cannot change the code to use MQ JMS not within the project timeframe atleast. Here's my code:

Code:


String [] folderContent = {"<usr><test><element1>sample</element1><element2>data</element2></test></usr>"};         
         
MQRFH2 rfh2 = new MQRFH2();
      
         System.out.println("MQRFH2 format: " + rfh2.getFormat());
         rfh2.setFormat(MQConstants.MQFMT_STRING);
         rfh2.setNameValueCCSID(1208);
         rfh2.setFolderStrings(folderContent);
         
         System.out.println("RFH2 header structure length: " + rfh2.getStrucLength());
         
         rfh2.write(inputMsg);


Thanks in advance.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Jun 07, 2013 6:10 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Have you taken into account the byte alignment for the user folder when looking at the length of the RFH?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
notoneword
PostPosted: Fri Jun 07, 2013 6:18 am    Post subject: Reply with quote

Apprentice

Joined: 17 May 2011
Posts: 37

Yaknow, I'm looking at the code that I ended up with and it's quite different from where I started.

Now, I'm using the MQMessage object to write the RFH2 fields, properly and in order. With name-value strings padded out to multiples of 4.
Back to top
View user's profile Send private message
prasadpav
PostPosted: Fri Jun 07, 2013 6:39 am    Post subject: Reply with quote

Centurion

Joined: 03 Oct 2004
Posts: 142

fjb_saper wrote:
Have you taken into account the byte alignment for the user folder when looking at the length of the RFH?


The output of name-value data & the whole RFH2 data yielded this:

Code:
         
System.out.println("Folder size is: " + folderContent3[0].length());
System.out.println("RFH2 header NameValue portion length: " + rfh2.getNameValueLength());
         System.out.println("RFH2 header structure length: " + rfh2.getStrucLength());



Code:

Folder size is: 76
RFH2 header NameValue portion length: 80
RFH2 header structure length: 116


Name-value portion length = 80 + 36 (fixed MQRFH2 structure size) = 116. So, I guess there is nothing to worry to byte alignment. Besides, when I use "setFolderStrings()" method, it'll automatically set the RFH2 structure length. In case if I understood your byte alignment suggestion wrong, then could you please elaborate more.

Also, please note that it works if I don't set the format field.

I also tried adding "mcd" folder along with "usr" folder without any success. I got the hint for adding "mcd" folder when looked at the output generated by the Message Broker v7 in creating the same message.:

Code:
{"<mcd><Msd>MQSTR</Msd></mcd>", "<usr><test><element1>Sample</element1><element2>Data</element2></test></usr>"};
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Adding MQRFH2 using MQHeaderList, getting MQRC_RFH_ERROR
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.