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 » EBCDIC to ASCII or Unicode

Post new topic  Reply to topic
 EBCDIC to ASCII or Unicode « View previous topic :: View next topic » 
Author Message
cymli
PostPosted: Sun Feb 10, 2002 12:28 am    Post subject: Reply with quote

Newbie

Joined: 09 Feb 2002
Posts: 2

Hi all,

We encounter problem on how to convert the EBCDIC code from Mainframe to ascii or unicode to display in the brower. We use IBM MQSeries v5.2 on AIX and VSE (OS/390). The default CCSID on VSE is 500 and that of AIX is 819, we use MQ JMS problem to send/receive the message to/from Mainframe. The code segment we use to receive the message is shown as following:

import javax.jms.*;

QueueConnection queueConnection;
Queue inQueue;
QueueReceiver queueReceiver;
Message receiveMessage;

..(Suppose We have created all the JNDI object for JMS)

//Receive message part
queueReceiver = queueSession.createReceiver(inQueue);
queueConnection.start();
receiveMessage = queueReceiver.receive();

if (receiveMessage != null){
String s = (receiveMessage instanceof TextMessage) ? ((TextMessage) receiveMessage).getText() : null;

((BytesMessage)receiveMessage).toString();
......
// Display message to broswers

After execute the above code, we find that the receiveMessage is the instance of BytesMessage, not TextMessage. Therefore, we don't know how to extract the message from the BytesMessage. If we execute this: ((BytesMessage)receiveMessage).toString(); we can see the message header and body information, the message content is ebcdic (C2D44040404040404....etc). I would like to know how to handle this BytesMessage and convert it to ASCII or unicode and final extract the message content part so as to display it on the browser. Also, is it necessary to convert the message in programming level? Thanks.

Catherine


Back to top
View user's profile Send private message
jirim
PostPosted: Sun Feb 10, 2002 3:39 am    Post subject: Reply with quote

Newbie

Joined: 09 Feb 2002
Posts: 3

I am not expert in MQ, but I solved some similar problem with Java MQ not with JMS. I hope it can help you.
I think it is problem on sending site no with receiving.
I appear as incorrect definition of message format (should be "MQSTR").
You must define characterSet=500 before write to message.
If you will have still problem, send part of code for writing message.

Regards

Jiri
Back to top
View user's profile Send private message
cymli
PostPosted: Sun Feb 10, 2002 5:18 am    Post subject: Reply with quote

Newbie

Joined: 09 Feb 2002
Posts: 2

jirim,

I tried IBM MQ class before and I successfully receive the message from host (not EBCDIC). I think it is because IBM MQ is IBM specific implementation to MQSeries and therefore it provide many features to access MQSeries, in my MQ code, I do this:

MQQueueManager qmgr = new MQQueueManager("QM1");
MQQueue queue = new MQQueue();
queue.accessQueue("Q1", null, null, null);
MQGetMessageOption qmo = new MQGetMessageOption();

MQMessage msg = new MQMessage();
msg.characterset = 500;
queue.get(msg, gmo);
String text = msg.readLine();
System.out.println("Text content: " + text);
System.out.println("Finished Receiving");

However, I found if I use JMS code, the return message is a bytesMessage and I don't know how to get the text content from the bytesMessage and also to decode it to ASCII or unicode for display.

Back to top
View user's profile Send private message
jirim
PostPosted: Sun Feb 10, 2002 10:49 am    Post subject: Reply with quote

Newbie

Joined: 09 Feb 2002
Posts: 3

Catherine,

I would like to explain you possible source of the problem.

You want resolve problem on receiving site, but I think problem is on sending site.
I am afraid that you create message incorectly. Message must be defined with text format attribute. Bellow I enclosed sample code on sending site.

MQMessage msg = new MQMessage();
msg.characterSet = 500; // your EBCDIC encoding, default encoding is 819
msg.format = "MQSTR ";
msg.writeString("Test string");
mqQueue.put(msg, mgo);

On receiving site try to correct it to:

MQMessage msg = new MQMessage();
// msg.characterset = 500; It is redundant, it is setup in MQ message
queue.get(msg, gmo);
String text = msg.readLine();
System.out.println("Text content: " + text);
System.out.println("Finished Receiving");

If you want correct it on receiving site, try read it as byte array. Select apropriate part of array and convert it to stream. Read text from stream with appropriate encoding (CCSID=500 is ebcdic-cp-be or ebcdic-cp-ch).

Jiri
Back to top
View user's profile Send private message
jirim
PostPosted: Sun Feb 10, 2002 12:23 pm    Post subject: Reply with quote

Newbie

Joined: 09 Feb 2002
Posts: 3

Catherine,

Excuse me, I didn't understand you.
I was seeing on manual for JMS. I think something is wrong on the sending site. May be missing or incorrect setting for the CCSID/character set or the type of the message on your VSE site. You can convert received object as I note on the bottom of my previous message.

Jiri
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 » EBCDIC to ASCII or Unicode
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.