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 » 2 bytes more send as expected [URGENT HELP NEEDED]

Post new topic  Reply to topic
 2 bytes more send as expected [URGENT HELP NEEDED] « View previous topic :: View next topic » 
Author Message
Takidoso
PostPosted: Thu Mar 08, 2007 4:47 am    Post subject: 2 bytes more send as expected [URGENT HELP NEEDED] Reply with quote

Novice

Joined: 08 Mar 2007
Posts: 19
Location: Germany

Hello
I am a newbie to MQ-Series and hope this forum is the right address for my problem.

I have a programm that is supposed to write MQ-messages that look very much like xml data. The funny thing is that 2 bytes more then expected arrive to the Host the queue addresses to.
it lookes then like this:

00000000: 0C8D 3031 524F 5554 2020 2020 424E 4B46 '..01ROUT BNKF'
but the 2 bytes 0C8D are not expected and not wanted, since I dont write them conciously and the partner on the other side seem to have trouble with them.
I have also a little programm to get a mesage of teh very same queue that gets the message as I expect without those 2 bytes.

the code that puts the message looks like that
Code:

public void put(String xml) throws IOException
    {
        putCounter++;
        mqLogger.fine(xml);
        mqLogger.fine(putCounter+". msg-length="+xml.length());
        MQPutMessageOptions pmo = new MQPutMessageOptions();
        //pmo.options = MQC.MQPMO_NONE;
        MQMessage mBuf = new MQMessage();
        mBuf.clearMessage();
        mBuf.correlationId = MQC.MQCI_NONE; // this acts as filter when you browse the queue!
        mBuf.messageId     = MQC.MQMI_NONE; // if MQMI not set, so everyone can
        mBuf.format        = MQC.MQFMT_STRING;

        // use the queue
        mBuf.writeUTF(xml);
        mqLogger.log(Level.FINE, "put message to request queue");
        try
        {
            requestQueue.put(mBuf, pmo);
        }
        catch (MQException mqEx)
        {
            mqLogger.log(Level.SEVERE,
                    "Error during putting the message into the queue " + requestQueueName + " \n" + printMQEnvironment(), mqEx);
            throw new IOException(mqEx.toString());
        }
    }


the code retaining the message looks like that:

Code:

    public String get() throws IOException
    {
        MQGetMessageOptions gmo = new MQGetMessageOptions();
        // gmo.options = MQC.MQGMO_NONE;
        MQMessage mBuf = new MQMessage();
        mBuf.clearMessage();
        mBuf.correlationId = MQC.MQCI_NONE; // this acts as filter when you
        mBuf.messageId = MQC.MQMI_NONE; // if MQMI not set, so everyone can
        try
        {
            replyQueue.get(mBuf, gmo);
            mqLogger.fine(mBuf.toString());
        }
        catch (MQException mqEx)
        {
            if (mqEx.reasonCode != MQ_REASON_CODE_NO_MESSAGE_AVAILABLE)
            {
                mqLogger.log(Level.SEVERE, "Error during getting the message from the queue " + replyQueueName + " \n"
                        + printMQEnvironment(), mqEx);
                throw new IOException(mqEx.toString());
            }
            else
            {
                return null;
            }
        }
        return mBuf.readUTF();
    }


Well I have the suspect that the writeUTF(String) method writes those bytes and the reatUTF() might cut out those 2 bytes in start of the message content again.

Is my suspect right? but how should it be coded instead to ommit those 2 bytes? Or is there some configuration to be done to solve my problem?

thanks in advance
Takidoso
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Mar 08, 2007 4:53 am    Post subject: Reply with quote

Grand High Poobah

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

I suspect the 2 bytes in question are the length field for the Unicode string. You should always use the writeUTF/readUTF as a pair. If your partner is using read rather than readUTF he'll pick them up in the way you describe.

You should write the message using the method that matches how he's reading it.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Takidoso
PostPosted: Thu Mar 08, 2007 5:56 am    Post subject: Reply with quote

Novice

Joined: 08 Mar 2007
Posts: 19
Location: Germany

Hi Vitor,
yes,this was also my suspect, about the 2bytes.
I try it now using the writeChars(String) method
and the readLine() method. May be I am lucky and it works.

thanks for your suggestion

Takidoso
Back to top
View user's profile Send private message
Takidoso
PostPosted: Thu Mar 08, 2007 6:13 am    Post subject: Reply with quote

Novice

Joined: 08 Mar 2007
Posts: 19
Location: Germany

well that does not work either
the 2 bytes that where to much are gone now, but on the host the string is writen now in 2 bytes each character.
Can anybody tell me what write-method and read method I am suppossed to use, when the string are just to be in singel characters without any uniccode 2byte-header?
Is terhe a possibility to configer the MQ-Message so that it is working right? may be in assigning an 8-byte uniccode set?

Thanks a lot in advance

Takidoso
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Mar 08, 2007 6:20 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Don't use readUTF and writeUTF. Generally ever.

Just readString and writeString.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Takidoso
PostPosted: Thu Mar 08, 2007 7:46 am    Post subject: Reply with quote

Novice

Joined: 08 Mar 2007
Posts: 19
Location: Germany

Hi jefflowrey,
thanks to your hint. I am also now trying that but I use still readLine, since my developing envrionment tells me that readString is depreicated.

I hope on the host ist still someone there who can tell me what the results are.

Takidoso
Back to top
View user's profile Send private message
zpat
PostPosted: Thu Mar 08, 2007 7:47 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

Byte Order Mark is the 2 bytes added at the start.

Using WriteString instead.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Mar 08, 2007 4:14 pm    Post subject: Reply with quote

Grand High Poobah

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

Takidoso wrote:
well that does not work either
the 2 bytes that where to much are gone now, but on the host the string is writen now in 2 bytes each character.
Can anybody tell me what write-method and read method I am suppossed to use, when the string are just to be in singel characters without any uniccode 2byte-header?
Is terhe a possibility to configer the MQ-Message so that it is working right? may be in assigning an 8-byte uniccode set?

Thanks a lot in advance

Takidoso

Well for the message to be read correctly make sure you are setting the format to MQFMT_STRING.

Now on the receiver side you will need the gmo option CONVERT.

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » 2 bytes more send as expected [URGENT HELP NEEDED]
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.