Author |
Message
|
Matrin |
Posted: Thu Feb 21, 2008 9:18 am Post subject: Weird Characters when Putting a Message to a Queue |
|
|
Novice
Joined: 14 Feb 2008 Posts: 10
|
Hi folks,
I am having a Java program that reads from a socket and puts the data in a queue. I have noticed that the message being put in the queue could not be read, and it has a weird characters at the beginning.
At first i suspected that this character might have came from the data being read from the socket. but when trying to hard-code some data and putting it in the queue, the same characters appeared.
I really dont know what is the problem..
and really need your help
Thanks  |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Feb 21, 2008 9:22 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
us to you.
Show your code. Post a sample of the "weird" characters.
Describe your problem in detail. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Matrin |
Posted: Fri Feb 22, 2008 1:48 am Post subject: |
|
|
Novice
Joined: 14 Feb 2008 Posts: 10
|
Hey Jef...
Here is part of the code which i believe causes the problem...
The charecters are .| and .[
Code: |
private boolean SBBATMCORESendMQ(String myMessage){
boolean bReturn = false;
try {
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
MQQueue que_OutputQue = m_qMgr.accessQueue("MQ.OUT", openOptions);
MQMessage msg_Message = new MQMessage();
msg_Message.expiry = m_iQMessageExpiry;
msg_Message.writeUTF(myMessage);
MQPutMessageOptions pmo = new MQPutMessageOptions();
que_OutputQue.put(msg_Message, pmo);
que_OutputQue.close();
}
.
.
.
.
.
|
|
|
Back to top |
|
 |
Vitor |
Posted: Fri Feb 22, 2008 1:51 am Post subject: Re: Wiered Characters when Putting a Message to a Queue |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Matrin wrote: |
I have noticed that the message being put in the queue could not be read, and it has a wiered characters at the begennig.
|
Could not be read why? MQ reason code? If so what?
If the message could not be read, by what means are you seeing the wierd characters? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
zpat |
Posted: Fri Feb 22, 2008 2:08 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Apart from anything else, it is bad practice to open an output queue for input + output.
Why? Just wait until you try and use a remote queue def and then you will find out!
Use WriteString or Text or whatever is the correct language construct.
If you use UTF, you must expect Byte Order Mark characters to appear at the start (and the CCSID will probably not match the data).
BOM, BOM ! as they say.... |
|
Back to top |
|
 |
Vitor |
Posted: Fri Feb 22, 2008 2:37 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
zpat wrote: |
If you use UTF, you must expect Byte Order Mark characters to appear at the start (and the CCSID will probably not match the data).
BOM, BOM ! as they say.... |
Good point I say!!
The "weird characters" probably are the UTF header.
Be sure you read the message with the matching method - if you use writeUTF you must use readUTF, if you use writeText use readText and so forth. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Feb 22, 2008 4:26 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You never want to use write/readUTF unless you know exactly what they do, and exactly what UTF is, and how it's different than Unicode. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Matrin |
Posted: Sun Feb 24, 2008 3:49 am Post subject: |
|
|
Novice
Joined: 14 Feb 2008 Posts: 10
|
Heey guys,
Thanks for your comments...
I tried using write string and it worked
thanks alot  |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Feb 24, 2008 6:04 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Matrin wrote: |
Heey guys,
Thanks for your comments...
I tried using write string and it worked
thanks alot  |
As well make sure if your message is all String to set the format to MQFMT_STRING
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
|