Author |
Message
|
EddieA |
Posted: Tue Mar 22, 2005 10:17 pm Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Quote: |
theMsg.writeInt4(MQC.MQRFH_STRUC_LENGTH_FIXED_2 + jmsfolderLength + 4 + usrfolderLength + 4 + mcdfolderLength + 4); |
No. You have to make the length of each "folder" to be a multiple of 4, not add 4.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
tricky_knight |
Posted: Wed Mar 23, 2005 6:47 am Post subject: |
|
|
Apprentice
Joined: 12 Mar 2005 Posts: 34
|
ok...
A- so that line of code would look like?
B- why must it be a 'multiple of 4?
please elaborate |
|
Back to top |
|
 |
EddieA |
Posted: Wed Mar 23, 2005 7:56 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
**EDIT** Below changed, I hope before anyone spotted my blunder.
A. It's not that line of code that needs to change, as that is correct. The wording on my previous post was not really clear in what I was trying to say. You have to pad each of the "folders" so that the length of each is a multiple of 4 before you add them to the RFH2. I'm not really a Java programmer, so I'm not going to make a fool of myself by attempting.
B. Because it's a requirement as stated in the manual:
Quote: |
NameValueData (MQCHARn)
Name/value data.
This is a variable-length character string containing data encoded using an XML-like syntax. The length in bytes of this string is given by the NameValueLength field that precedes the NameValueData field; this length should be a multiple of four.
|
And:
Quote: |
NameValueLength (MQLONG)
Length of NameValueData.
This specifies the length in bytes of the data in the NameValueData field. To avoid problems with data conversion of the data (if any) that follows the NameValueData field, NameValueLength should be a multiple of four.
|
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
tingwen |
Posted: Mon Aug 22, 2005 10:29 am Post subject: |
|
|
Novice
Joined: 19 Aug 2005 Posts: 24
|
In sample code, is '//4) + rf);' just a comment line here?
wen |
|
Back to top |
|
 |
gorilla |
Posted: Fri Nov 18, 2005 12:29 am Post subject: Folder lengths |
|
|
Novice
Joined: 17 Nov 2005 Posts: 16
|
Last week I needed some Java code for WMB PubSub via Java, and used the information in this thread to create the headers (thanks to those who provided sample code).
I couldn't understand the folder-length logic shown here though - I didn't see why adding 4 to the actual length of a folder would have any effect - so I ran some tests, and thought I might as well share the results, such as they are:
* Messages with a folder which isn't the right length finished up in the DLQ
* When I padded the folders with blanks to round them to a multiple of 4 characters they worked fine
* I use the actual length of the folder in the header length field (i.e. I don't add 4 to the length)
* The code to make valid folders from command strings is trivial, but I've included it below anyway (sorry for the poor formatting - this is my first post here).
* I made an RFH2 class too, but it's very simple - is there somewhere I can get a good one? Alternatively, is there any point in making some "Q&D" classes for RFH2 and PubSub commands available somewhere on mqseries.net (they aren't well coded, but at least they work
public class RFH2Folder {
private int length ;
private String folderContent ;
/**
* Constructor
*/
public RFH2Folder( String pFolderContent) {
super() ;
this.folderContent = padString( pFolderContent ) ;
this.length = folderContent.length() ;
}
/*
* Pad to length = multiple of 4
*/
private static String padString( String unpaddedString ) {
if ( unpaddedString == null ) unpaddedString = "" ;
String paddedString = new String( unpaddedString );
String filler= " " ;
int x = unpaddedString.length() % 4 ;
if ( x != 0 ) paddedString += filler.substring( 0, 4 - x ) ;
return paddedString ;
}
public String getFolderContent() {
return folderContent;
}
public int getLength() {
return length;
}
} |
|
Back to top |
|
 |
EddieA |
Posted: Fri Nov 18, 2005 9:02 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Quote: |
I didn't see why adding 4 to the actual length of a folder would have any effect |
You have to account for the length of the "length" in the overall length.
Quote: |
I use the actual length of the folder in the header length field (i.e. I don't add 4 to the length) |
But you need to. That 4 is for the field that holds the length of the folder.
So, if you have:
Code: |
RFH2 Header
Length of Folder A
Folder A
Length of Folder B
Folder B
Length of Folder C
Folder C |
And the value you store in the RFH2 for it's length is: MQC.MQRFH_STRUC_LENGTH_FIXED_2 + 4 + Length of Folder A + 4 + Length of Folder B + 4 + Length of Folder C.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
nag_kancharla |
Posted: Thu Feb 12, 2009 12:26 am Post subject: RFH header also being considered as message body |
|
|
Newbie
Joined: 11 Feb 2009 Posts: 1
|
I have used “public MQMessage buildRFH2Header(MQMessage msg) throws IOException” method what Mikhail had provided. I have encountered a problem. The RFH Header is being considered as the Message body after the message is absorbed into the message flow.
What I have done is here:
MQMessage msg = new MQMessage();
this.buildRFH2Header(msg);
After framing the RFH2 header,
msg.writeObject (obj);
I wrote my input message to the msg object.
queue.put(msg,pmo);
Put the message in the queue.
Is that the correct way to frame a message with RFH2 Header? Please help me here.
Regards,
Nag. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Feb 12, 2009 8:55 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20763 Location: LI,NY
|
OK let's put a stop here. This method is really for the purists that have the time on their hands.
Nowadays there is little difference in performance between base java and JMS. So use JMS already and the RFH is handled behind the scenes for you.
If you are that strapped for performance maybe you should really switch from java to c or c++.
I sincerely believe that the time spent trying to create the RFH header in java base would have been more profitably used learning JMS. On top of this, using java base, you still have to do the header chaining.... This too is done by JMS behind the scenes for you. And if you don't need an RFH on the message JMS can do that too.
Anyways have fun learning programing  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|