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 » Error 2334 (Invalid RFH2) - Fixed ! But 1 more question...

Post new topic  Reply to topic
 Error 2334 (Invalid RFH2) - Fixed ! But 1 more question... « View previous topic :: View next topic » 
Author Message
martinstephenson
PostPosted: Fri Jun 17, 2005 8:40 am    Post subject: Error 2334 (Invalid RFH2) - Fixed ! But 1 more question... Reply with quote

Newbie

Joined: 17 Jun 2005
Posts: 7

Hi,

I have the following code to set the mcd and jms folder in an MQMessage:

Code:

    private final static String MCD_FOLDER   = "<mcd><Msd>xml</Msd><mcd>";
    private final static String JMS_FOLDER   = "<jms></jms>";

    private void addRFH2(MQMessage theMsg) throws IOException
    {
        int mcdFolderLength = MQQueueWriter.MCD_FOLDER.length();
        int jmsFolderLength = MQQueueWriter.JMS_FOLDER.length();
        int mqStructLen = MQC.MQRFH_STRUC_LENGTH_FIXED_2 + mcdFolderLength + jmsFolderLength + 4 + 4;
       
        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(mqStructLen);         // StrucLength
        theMsg.writeInt4(MQC.MQENC_NATIVE);      // Encoding
        theMsg.writeInt4(MQC.MQCCSI_DEFAULT);   // CodedCharacterSetId
        theMsg.writeString(MQC.MQFMT_STRING);   // Format
        theMsg.writeInt4(MQC.MQRFH_NO_FLAGS);   // Flags
        theMsg.writeInt4(1208);               // NameValueCCSID = UTF-8
        theMsg.writeInt4(mcdFolderLength);
        theMsg.writeString(MQQueueWriter.MCD_FOLDER);
        theMsg.writeInt4(jmsFolderLength);
        theMsg.writeString(MQQueueWriter.JMS_FOLDER);
   }



The line
Code:
        theMsg.writeString(MQC.MQFMT_STRING);   // Format


Is the problem - it's fine if I set it to
Code:
        theMsg.writeString(MQC.MQFMT_NONE);   // Format


Setting it to string is the problem.

I'm trying to get the WBI Adapter Framwork to accept Business Objects from a japa program. The working message that the Framework accept have the "Data Format" set to "MQSTR " if I view a working message with rfhutil.exe

Am I doing something obviously wrong ?


Last edited by martinstephenson on Mon Jun 20, 2005 4:55 am; edited 1 time in total
Back to top
View user's profile Send private message
EddieA
PostPosted: Fri Jun 17, 2005 9:04 am    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Is MCD_FOLDER a multiple of 4 characters. Is JMS_FOLDER a multiple of 4 characters.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
martinstephenson
PostPosted: Fri Jun 17, 2005 12:59 pm    Post subject: Reply with quote

Newbie

Joined: 17 Jun 2005
Posts: 7

You could actually be helpful by explaining instead of being sarcastic..

"There are no stupid questions...." I think you know the rest
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Jun 17, 2005 1:15 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

martinstephenson wrote:
You could actually be helpful by explaining instead of being sarcastic..

"There are no stupid questions...." I think you know the rest


I really don't think you know whether EddieA was being sarastic or not. Just like you really don't know what tone or mood I'm in when I'm posting this response.

It looked to *me* like he was simply asking some basic questions.

And they seemed kind of helpful, as well. He told you to check to see if your MCD_FOLDER length was an even multiple of 4 bytes, and the same with the JMS_FOLDER. And a basic read through of the description of the RFH2 header would have *also* told you that.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Jun 17, 2005 5:55 pm    Post subject: Reply with quote

Grand High Poobah

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

Maybe an even more fundamental question:

a) you seem to be using base java to do this
Why worry and go to all the trouble when you could be doing it in a much easier way using the JMS classes for java ??

Enjoy
Back to top
View user's profile Send private message Send e-mail
martinstephenson
PostPosted: Fri Jun 17, 2005 11:57 pm    Post subject: Reply with quote

Newbie

Joined: 17 Jun 2005
Posts: 7

OK, sorry - maybe he wasn't being sarcastic at all - I'm just fustrated trying to get this to work - apologies.

I'm working on a project and MQ is only a tiny part of it and I honestly don't have time to sit down and read through the whole "Using MQ" pdf file - the development schedule has way too much other stuff on it - I looked at the part about RFH2 headers in the document and it talked about properties that could be set, but it wasn't obvious (to me) how to set these and since I've no experience of JMS either I didn't know how to set them.

In all honesty - I just want a plain English explanation of how to do this - the code I already posted was taken from an example off this forum and I assumed this was the way to go.

Gotta love IBM - working there and nobody there seems to have a clue about MQ and Java (in my dept, that is).
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Jun 18, 2005 3:50 am    Post subject: Reply with quote

Grand High Poobah

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

Well Martin, using jms you do something like this:

//get the context javax.naming.InitialContext
//Hashtable or Properties (impl of hashtbl)
Properties props = new Properties();
// set properties for initial context factory
// set properties for provider url
// set referal to throw
//get the qcf
QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("myqcf");
// alternatively use MQQConnectionFactory..... and set the props on it

//create queue connection
QueueConnection qcon = qcf.createQueueConnection();
//create session
QueueSession qs = qcon.createSession(true,Session.AUTO_ACKNOWLEDGE);
//get the q
Queue myqueue = (Queue) ctx.lookup("myqueue");
//alternative
//no qmgr specified will default to the one of the connection
myqueue = qs.createQueue("queue:///myqueuename"); //do not add targetClient=1 as this would suppress RFH header
//create sender
Sender sdr = qs.createSender(myqueue);

//create message
TextMessage tm = qs.createTextMessage();
tm.setText("this is the message body");

//set properties
tm.setProperty(.....); //check out the API. This goes into RFH header
//send
sdr.send(tm);

//cleanup
sdr.close();
qs.commit();// it was created transacted
qs.close();
qcon.close();

//done.

For the rest and the details read the manuals.

Enjoy
Back to top
View user's profile Send private message Send e-mail
martinstephenson
PostPosted: Sat Jun 18, 2005 10:07 am    Post subject: Reply with quote

Newbie

Joined: 17 Jun 2005
Posts: 7

Big thanks for the help - I'll get into first thing Monday morning.

Regards,

M.
Back to top
View user's profile Send private message
martinstephenson
PostPosted: Mon Jun 20, 2005 3:14 am    Post subject: Reply with quote

Newbie

Joined: 17 Jun 2005
Posts: 7

OK - After coming in fresh today after the weekend - got this sorted.

It turned out to be a problem with the CodedCharacterSetId - I had it as MQCCSI_DEFAULT, but when I tried to set the format to MQFMT_STRING (changing from MQFMT_NONE) it gave an error.
It turned out that the CodedCharacterSetId had to be MQCCSI_INHERIT.

I found this out by examining the bytes set in my message header in Java, and the bytes in a valid message in a Hex editor.

My question is, however, why does it have to be set to MQCCSI_INHERIT ?

A search of the "Using Java" document returns no results for MQCCSI_INHERIT - is there some other document I should also have referred to find this out, instead of the way I had to find it out ?

For anyone interested - here's my code to set the RFH2 header :

Code:

    private final static String MCD_FOLDER   = "<mcd><Msd>xml   </Msd></mcd>";
    private final static String JMS_FOLDER   = "<jms> </jms>";

    public void addRFH2(MQMessage theMsg) throws IOException
    {
        int mcdFolderLength = MQQueueWriter.MCD_FOLDER.length();
        int jmsFolderLength = MQQueueWriter.JMS_FOLDER.length();
        int mqStructLen = MQC.MQRFH_STRUC_LENGTH_FIXED_2 + mcdFolderLength + jmsFolderLength + 4 + 4;
       
        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(mqStructLen);         // StrucLength
        theMsg.writeInt4(MQC.MQENC_NATIVE);      // Encoding
        theMsg.writeInt4(MQC.MQCCSI_INHERIT);   // CodedCharacterSetId
        theMsg.writeString(MQC.MQFMT_STRING);   // Format (content)
        theMsg.writeInt4(MQC.MQRFH_NO_FLAGS);   // Flags
        theMsg.writeInt4(1208);               // NameValueCCSID = UTF-8
        theMsg.writeInt4(mcdFolderLength);
        theMsg.writeString(MQQueueWriter.MCD_FOLDER);
        theMsg.writeInt4(jmsFolderLength);
        theMsg.writeString(MQQueueWriter.JMS_FOLDER);
   }

Back to top
View user's profile Send private message
EddieA
PostPosted: Mon Jun 20, 2005 8:40 am    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Quote:
is there some other document I should also have referred to find this out

The Application Programming Reference lists all the defined Data Types and MQ Constants.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
Nigelg
PostPosted: Mon Jun 20, 2005 11:43 pm    Post subject: Reply with quote

Grand Master

Joined: 02 Aug 2004
Posts: 1046

MQCCSI_INHERIT means that the current header, the RFH2, has the same CCSID as the previous header.
MQCCSI_NONE means that the CCSID of the header is 0, which is invalid for an RFH2.
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 » Error 2334 (Invalid RFH2) - Fixed ! But 1 more question...
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.