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 » Problem when getting from a remote queue...

Post new topic  Reply to topic
 Problem when getting from a remote queue... « View previous topic :: View next topic » 
Author Message
atoms
PostPosted: Mon Apr 03, 2006 8:05 am    Post subject: Problem when getting from a remote queue... Reply with quote

Apprentice

Joined: 10 Jun 2005
Posts: 27

I'm trying to do a "non-destructive" get from a queue and write the results to a file within a simple Java program. It all works fine when I run this program against a local queue manager set up on my machine. But when I connect to a remote machine and get a message from a queue, all i get is mumbo-jumbo, similar to this:

???????@@@?????????@@@@@@@@@@@%???????????????????@??

Here is the part of my code where I'm doing the actual parsing of each byte in the received message:

StringBuffer buf=new StringBuffer();
for(int i=0; i<retrievedMessage.getMessageLength(); i++){
Byte readCharacter=new Byte(retrievedMessage.readByte());
buf.append((char)readCharacter.intValue());
}

As you can see, it's not very complicated but for some reason it doesn't work when I connect remotely. If you have a clue why, please let me know! Thanks!
Back to top
View user's profile Send private message
mvic
PostPosted: Mon Apr 03, 2006 8:50 am    Post subject: Re: Problem when getting from a remote queue... Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

atoms wrote:
for some reason it doesn't work when I connect remotely.

Could it be that the app putting the the queue on the remote queue manager is producing text in a different CCSID? If it's a text message you might need to add MQGMO_CONVERT on your get options. (It's not clear that you are dealing with text, as I see lots of byte operations in the sample code you posted... do you expect bytes and text characters to be equivalent in the message you're getting?)

Also, it may help us to see the problem if you post a bit more of the code - eg. including the connect, open, and get.
Back to top
View user's profile Send private message
atoms
PostPosted: Mon Apr 03, 2006 12:12 pm    Post subject: Reply with quote

Apprentice

Joined: 10 Jun 2005
Posts: 27

Thank's for your reply! It is possible that the queue manager from which I'm getting the message is set up with a different CCSID, I need to check that out. The messages I'm dealing with are text messages. Perhaps I'm doing things in an unnecessarily complex way, I'm only a newbie... =)

Here's a bit more code:

private static final int openOptions=MQC.MQOO_BROWSE;
.
.
MQEnvironment.hostname="xxx.xxx.xxx.xxx";
MQEnvironment.channel="my.client.channel";

qmgr=new MQQueueManger(QUEUE_MANAGER);
queue=qmgr.accessQueue(QUEUE_NAME,openOptions);
MQMessage retrievedMessage=new MQMessage();
MQGetMessageOptions messageOptions=new MQGetMessageOptions();
messageOptions.options=MQC.MQGMO_BROWSE_FIRST;
queue.get(retrievedMessage, messageOptions);
.
.
.
Back to top
View user's profile Send private message
mvic
PostPosted: Mon Apr 03, 2006 12:32 pm    Post subject: Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

atoms wrote:
It is possible that the queue manager from which I'm getting the message is set up with a different CCSID, I need to check that out.

What's relevant is the content of the message. Look at the putting app, not the queue manager.

Quote:
The messages I'm dealing with are text messages.
...
messageOptions.options=MQC.MQGMO_BROWSE_FIRST;

What happens if you try the above with
Code:
messageOptions.options=MQC.MQGMO_BROWSE_FIRST | MQC.MQGMO_CONVERT;
Back to top
View user's profile Send private message
atoms
PostPosted: Mon Apr 03, 2006 10:37 pm    Post subject: Reply with quote

Apprentice

Joined: 10 Jun 2005
Posts: 27

That's brilliant, now it works! Many thanks!

So, the problem was that the sending app produced the message in a different CCSID? And this message option tells the queue manager to "translate" tha message according to my preferences (CodedCharSetId, Encoding) when I'm doing the get...?
Back to top
View user's profile Send private message
mvic
PostPosted: Tue Apr 04, 2006 12:12 am    Post subject: Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

atoms wrote:
That's brilliant, now it works! Many thanks!

Good news

Quote:
So, the problem was that the sending app produced the message in a different CCSID?

It seems this is the case, yes.

Quote:
And this message option tells the queue manager to "translate" tha message according to my preferences (CodedCharSetId, Encoding) when I'm doing the get...?

Exactly, yes.

See http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/topic/com.ibm.mq.csqzak.doc/convp.htm
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 » Problem when getting from a remote queue...
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.