Author |
Message
|
starki78 |
Posted: Mon Dec 01, 2008 7:31 am Post subject: format,characterset,encoding:How to understand this science? |
|
|
Acolyte
Joined: 24 Sep 2007 Posts: 53
|
Hi I'm using a Java-Client sending a message to MQ wih following setting:
mBuf.format= MQC.MQFMT_STRING ;
mBuf.characterSet = 500;
mBuf.encoding = 785;
I fetch the message (binary) with a Service Bus and:
see the values remain unchanged:
<mq:CharacterSet>500</mq:CharacterSet>
<mq:Encoding>785</mq:Encoding>
<mq:Format>MQSTR</mq:Format>
Now I first need to decode the message and want to have the correct format.
But I always fail.
I tried so may different CICCID
but always get something like:
ÞÀ` Î
I'm getting crazy but the problem es that this is like a Science:-)
Please advice!
Christian
Last edited by starki78 on Mon Dec 01, 2008 7:49 am; edited 1 time in total |
|
Back to top |
|
 |
Vitor |
Posted: Mon Dec 01, 2008 7:36 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Moved to correct section _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Dec 01, 2008 7:38 am Post subject: Re: Encoding: How to understand this science? |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
starki78 wrote: |
I'm getting crazy but the problem es that this is like a Science:-) |
Welcome to the world of professional software.
starki78 wrote: |
Please advice!
|
I advise you not to double post, especially when you keep posting in a inappropriate forum. Double posting is considered rude, is not going to get you an answer faster and if you don't like the answer you've been given, say so on the original thread - don't just start another one!  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Dec 01, 2008 7:43 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
For the record, the original thread is here , posted like this one in the Challenge section.
Maybe the MQ Java/JMS section needs a clearer, less ambiguous title? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
starki78 |
Posted: Mon Dec 01, 2008 7:50 am Post subject: |
|
|
Acolyte
Joined: 24 Sep 2007 Posts: 53
|
apologies for posting to the wrong forum.
Cheers
Christian |
|
Back to top |
|
 |
Vitor |
Posted: Mon Dec 01, 2008 7:52 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
starki78 wrote: |
apologies for posting to the wrong forum.
|
Posting twice to the wrong section. The same thing. Twice. Most people at least double post in 2 different sections.
For the record, if anyone does post in the wrong place don't re-post - just post a reply asking a mod to move it. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
starki78 |
Posted: Mon Dec 01, 2008 8:02 am Post subject: |
|
|
Acolyte
Joined: 24 Sep 2007 Posts: 53
|
I don't know how you can say that I posted twice.
I excused myself that I posted to the wrong forum then I changed the headline as you mentioned.
I had a question that was very important to me and thought to get some help on encoding.
Sorry again
Christian |
|
Back to top |
|
 |
Vitor |
Posted: Mon Dec 01, 2008 8:06 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
starki78 wrote: |
I don't know how you can say that I posted twice. |
This one, and the one I linked to (and indeed attempted to be helpful on, given my limited Java). _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
starki78 |
Posted: Mon Dec 01, 2008 8:57 am Post subject: |
|
|
Acolyte
Joined: 24 Sep 2007 Posts: 53
|
what I want to do is to simulate a mainframe system.
There the customer uses the mentioned values and the message also has to be in binary-mode.
Cheers
Christian |
|
Back to top |
|
 |
atheek |
Posted: Mon Dec 01, 2008 10:50 am Post subject: |
|
|
 Partisan
Joined: 01 Jun 2006 Posts: 327 Location: Sydney
|
A few points-
1. If the message has to be in binary and not text then you don't have to specify mBuf.format= MQC.MQFMT_STRING ; neither the character set, How do you know the customer sets it in binary mode. If they are specifying values for MQMD format as MQC.MQFMT_STRING and CCSID as 500, I would expect they are sending text messages.
2.If your aim is to put a message in Cp500 ( ebcdiic) format, just specifying mBuf.characterSet = 500 won't help. You need to ensure your java appln is indeed putting the message with this encoding and not the default character encoding of the environment. If you have the hex values of the message body you can use String(bytes[] byts, String enc)format of the String constructor to generate the string with Cp500 encoding and assign it to message body. Or you might be interested to look at java.nio.charset package for doing character set conversion. |
|
Back to top |
|
 |
starki78 |
Posted: Tue Dec 02, 2008 2:25 am Post subject: |
|
|
Acolyte
Joined: 24 Sep 2007 Posts: 53
|
thank you.
Your post was very helpful for my understanding.
Best regards
Christian |
|
Back to top |
|
 |
starki78 |
Posted: Tue Dec 02, 2008 4:09 am Post subject: |
|
|
Acolyte
Joined: 24 Sep 2007 Posts: 53
|
I've written a Demo_Programm that seems to work.
java.nio.charset.CharsetEncoder encoder = java.nio.charset.Charset.forName("Cp285").newEncoder();
java.nio.ByteBuffer buf = encoder.encode(java.nio.CharBuffer.wrap("test-ok-"));
byte b[] = buf.array();
mBuf.write(b);
java.nio.charset.CharsetDecoder decoder = java.nio.charset.Charset.forName("Cp285").newDecoder();
java.nio.CharBuffer buff = decoder.decode(buf);
System.out.println(buff.toString()+"buff");
System.out.println("put message to queue");
However in the Service Bus it does not work when I set the CCID to 285.
I get:
£…¢£`–’`
If anybody still has an idea I'd be grateful!
Cheers
Christian |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Dec 02, 2008 4:26 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Christian,
If you use JMS and you are not using the default CCSID setup you can force the message to get translated to a specific CCSID for your destination by the qmgr. You can either do that by setting the CCSID in JNDI on the destination or by setting the CCSID on the qcf.
Setting the CCSID on the destination will have the qmgr accept the message with the standard of the sending platform and translating to the CCSID requested for the JMS Destination in the JNDI at put time.
Setting the CCSID on the qcf will mean that you are producing/requesting the Messages in that CCSID and (only) TextMessages will be translated to that CCSID before being delivered to you.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
atheek |
Posted: Tue Dec 02, 2008 4:05 pm Post subject: |
|
|
 Partisan
Joined: 01 Jun 2006 Posts: 327 Location: Sydney
|
What is your service Bus..I mean which product?
Are you sure that you have configured service bus to use native java mq instead of jms? |
|
Back to top |
|
 |
|