Author |
Message
|
rsinha |
Posted: Fri Aug 29, 2003 7:07 am Post subject: How charset coversion takes place within JMS |
|
|
Apprentice
Joined: 29 Aug 2003 Posts: 42
|
Within MQ, when receiving messages from a queue, that may be in a different charset than the one that the receiving application wants it in, the receiving application can specify MQGMO_CONVERT in the call to MQGET. This tells the Q manager to do the charset conversion.
How do I achieve the same functionality using JMS? I've searched thru all the JMS classes that allow you to retrieve the message from the Q, but none of them allow you to set the flag MQGMO_CONVERT to tell Q manager to do the conversion. |
|
Back to top |
|
 |
EddieA |
Posted: Fri Aug 29, 2003 9:15 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
You don't have to. The way the IBM implementation of JMS works is that it does an Get without convert, BUT, when you use a readString, readInt, etc. the JMS implementation takes the CCSID and Encoding from the incoming message and uses it to do the translation on a field by field basis.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
rsinha |
Posted: Fri Aug 29, 2003 12:31 pm Post subject: |
|
|
Apprentice
Joined: 29 Aug 2003 Posts: 42
|
Does it mean, when I do following -
inMessage = mQueueReceiver.receiveNoWait();
String textMessage = ((TextMessage)inMessage).getText();
JMS implementation will change whatever the message's CCSID is and change it to utf-8?
Thanx |
|
Back to top |
|
 |
EddieA |
Posted: Sat Aug 30, 2003 5:03 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Well, it won't change the CCSID, but will use it to convert the string to UTF-8.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
Nikki |
Posted: Tue Oct 07, 2003 1:46 am Post subject: How do I specify the CCSID and encoding for the Application |
|
|
Newbie
Joined: 02 Oct 2003 Posts: 2
|
Hi Eddie,
Will the conversion be done automatically when the receiving end is a JMS Listener and inMessage below is of Type JMS Message and not an MQ Message ?
inMessage = mQueueReceiver.receiveNoWait();
String textMessage = ((TextMessage)inMessage).getText();
Also how does the IBM implementation of JMS determine what CCSID / Encoding is required by the receiving application ?
Your answers to these queries will help me a lot.
Thanks !
Nikki |
|
Back to top |
|
 |
EddieA |
Posted: Tue Oct 07, 2003 9:42 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
If you use type TextMessage, then yes, the implementation will try and convert.
Doesn't Java use UTF-8 intenally for all strings.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
Nikki |
Posted: Tue Oct 07, 2003 10:17 am Post subject: |
|
|
Newbie
Joined: 02 Oct 2003 Posts: 2
|
Hi Eddie,
Thanks for your response.
I wanted to make sure that I do not have to do anything explicitly on the receiving application end  |
|
Back to top |
|
 |
Wbrant |
Posted: Tue Oct 14, 2003 4:22 pm Post subject: Character Set conversion |
|
|
Novice
Joined: 22 Aug 2003 Posts: 10
|
HI,
I have been looking at the CCSID settings and the encoding types. I have a small Java class that contructs a Text string by using character codes.
What i would expect is wehen i submitt a text message with a character of
(char)255. I would expect to see in the WebsphereMQ explorere a corresponding hex character of FF.
Can you point me to a encoding set that will let give me a corresponding baseline so i can verify my character codes are working as expected.
com.ibm.mq.jms.MQQueue.setCCSID(850);
com.ibm.mq.jms.MQQueue.setEncoding(546);
for(int ii= 255;ii >=1 ;ii--)
{
sb.insert(0, (char) ii);
TxtMsg.setText(sbsr1.toString());
}
I think mqseries is doing an automatic character set conversion.
thanks for any help |
|
Back to top |
|
 |
Wbrant |
Posted: Sat Oct 25, 2003 12:26 pm Post subject: Automtic MQ Series Conversion |
|
|
Novice
Joined: 22 Aug 2003 Posts: 10
|
HI,
MQ Series IS not necessarily doing a conversion however you must make sure that you using the proper encoding set for you Platform.
Below is an excerpt from one of pages i have book marked. I have been unable to find this information anywhere else.
I.E. Windows, MainFrame, AS400 etc.
Believe it or not there may be hundreds of ASCII and EBCDIC coded character sets customized for this and that purpose. Here are some of the more popular coded character sets:
CCSID 037 - EBCDIC "US English" code page on OS/400 and VSE/ESA.
CCSID 437 - ASCII code page on DOS and Windows DOS Console.
CCSID 500 - EBCDIC "International" code page on MVS.
CCSID 850 - ASCII code page on UNIX systems and PCs in Europe.
CCSID 819 - ASCII (Latin-1) code page (ISO 8859-1 standard Western European).
CCSID 1252 - ASCII code page on Windows 95 NT and up. |
|
Back to top |
|
 |
AmitN |
Posted: Thu Apr 18, 2013 8:44 am Post subject: |
|
|
Novice
Joined: 04 Apr 2013 Posts: 10
|
Am using the same code in my environment but it not working here -
if (message instanceof TextMessage)
{
try {
String sChangeMessage = ((TextMessage) message).getText();
}
catch (JMSException ex) {
LOG.error(ex.getMessage());
}
}
Am getting junk character for eg - C5E4F0F340404040. Anything m missing here. |
|
Back to top |
|
 |
zpat |
Posted: Thu Apr 18, 2013 10:07 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
IBM keep changing their mind about where data conversion is done with JMS.
JMS used to do it, then the queue manager was used to do it, now JMS does it again.
It depends what fixpack level you have and/or what environment variables you set. |
|
Back to top |
|
 |
rekarm01 |
Posted: Sat Apr 20, 2013 2:57 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
Re-opening a nearly ten-year old thread? Is that a record? Applications can convert from input bytes to characters, or from characters to output bytes, or both (from input bytes to output bytes). The charset/ccsid/etc. is associated with the physical bytes, not the logical characters; the internal representation of characters is not directly relevant.
AmitN wrote: |
Am using the same code in my environment but it not working here -
Code: |
if (message instanceof TextMessage) {
try {
String sChangeMessage = ((TextMessage) message).getText();
}
...
} |
|
The TextMessage setText() or getText() methods do not use bytes, so they don't need to convert them to/from characters. The String returned by getText() is the same String passed to setText(). Any byte<-->char conversions would take place before the call to setText(), or after the call to getText().
AmitN wrote: |
Am getting junk character for eg - C5E4F0F340404040. Anything m missing here. |
Try to identify where any conversion(s) take place, and post that code, along with any relevant data. |
|
Back to top |
|
 |
AmitN |
Posted: Fri Apr 26, 2013 1:42 am Post subject: |
|
|
Novice
Joined: 04 Apr 2013 Posts: 10
|
@rekarm01... Not sure about the record...
Do you mean casting to text message does not do the conversion?
Receiving message is in xml format and message's body has these juink characters.
I have tried using this too -
byte[] by = ((TextMessage) message).getText().getBytes("ISO-8859-1");
String sChangeMessage = new String(by,"UTF-8");
but no luck.. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Apr 26, 2013 4:50 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
you are looking for a code solution at the receiving end. WRONG approach!
First inspect the incoming message. What is the value of the MQMD-FORMAT field?
What is the value of the MQMD-CCSID field?
What is the value of the MQMD-ENCODING field?
As you are on the receiving end of the message you need to first make sure everything is being sent the right way.
Let us know about your finds.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
AmitN |
Posted: Fri Apr 26, 2013 7:19 pm Post subject: |
|
|
Novice
Joined: 04 Apr 2013 Posts: 10
|
HI fjb_saper,
These messages are sent by DB2 Event publisher ,
Message format set to xml.
Message codepage set to 1208
Are these MQMD parameters set by MQ or by application? |
|
Back to top |
|
 |
|