Author |
Message
|
gifs71 |
Posted: Mon Mar 14, 2005 12:03 am Post subject: Setting message CCSID using MQ JMS API |
|
|
Novice
Joined: 05 Aug 2004 Posts: 13
|
I am trying to figure out how to set the CCSID (coded character set) of a message been written to a MQ queue using a JMS client. I can't use the default CCSID of that queue since messages being written to that queue can have varying CCSID values.
In the MQ base Java API one can set this value by setting the value of the character encoding property of the MQMessage object. But I am having trouble trying to do the same thing using MQ JMS API.
Any help will be appreciated.
Thanks. |
|
Back to top |
|
 |
fschofer |
Posted: Mon Mar 14, 2005 5:39 am Post subject: |
|
|
 Knight
Joined: 02 Jul 2001 Posts: 524 Location: Mainz, Germany
|
Hi,
search for JMS_IBM_Character_Set in the "Using Java" manual.
Greetings
Frank |
|
Back to top |
|
 |
gifs71 |
Posted: Mon Mar 14, 2005 5:13 pm Post subject: |
|
|
Novice
Joined: 05 Aug 2004 Posts: 13
|
Hi,
Thanks for the pointer regarding the "JMS_IBM_Character_Set" property. |
|
Back to top |
|
 |
gifs71 |
Posted: Wed Mar 16, 2005 2:22 pm Post subject: |
|
|
Novice
Joined: 05 Aug 2004 Posts: 13
|
Hi,
When I do a getStringProperty("JMS_IBM_Character_Set") on a Message object instance I get the character set as a string description, say UTF8, instead of the integer 1208. Performing a getIntProperty("JMS_IBM_Character_Set") gives a NumberFormatException. It is obvious that the character set property is stored as a String rather than a integer. In case of base MQ Java API the character set was represented by an integer value.
The question is how do I get the int value using the JMS API?
Thanks. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Mar 17, 2005 4:20 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
What do you need it for ?
JMS should do a get with convert by default.
If it is to set the CCSID you have to do this through JNDI.
It is set as default at queue level and causes all messages put to that queue to have that CCSID.
Enjoy  |
|
Back to top |
|
 |
gifs71 |
Posted: Thu Mar 17, 2005 12:03 pm Post subject: |
|
|
Novice
Joined: 05 Aug 2004 Posts: 13
|
Hi,
As I said earlier I need the CCSID value for each message because I need to write the messages to another queue and the requirements is to preserve the message as it is, including, meta information, especially CCSID. Hence, I cannot use the CCSID default value of that queue because the messages Put to that queue can have varying CCSID values and I need to preserve them.
Any help will be appreciated.
Thanks. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Mar 17, 2005 12:13 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Don't understand your requirement.
Multiple ways to handle it.
a) Have the messages routed directly to their destination using alias queues.
b) Reroute messages using qmgr alias
c) programming get the message. Do not get the payload. Put the message. Commit if under syncpoint
Enjoy  |
|
Back to top |
|
 |
gifs71 |
Posted: Thu Mar 17, 2005 5:14 pm Post subject: |
|
|
Novice
Joined: 05 Aug 2004 Posts: 13
|
Ok. Here is the scenario:
The application connects to two queues on a MQSeries instance, say, Queue A and Queue B. Application needs to process messages coming on Queue A and if the message cannot be processed for whatever reason by the app then the message is supposed to be put onto the Queue B.
When a message is picked up from Queue A its contents are extracted from the message in a byte array and its CCSID value held by the app. In case of error, when the message needs to be written to the Queue B, the app construts a new message with the contents extracted earlier and sets the value of CCSID of that message to whatever value it has been holding. So now when I was using the base MQ Java API I could get the CCSID value as an int value, but with JMS I get it as a String. So when using JMS I can set the CCSID of the message as follows:
messageInstance.setStringProperty("JMS_IBM_Character_Set", "1208");
Hence, I need the CCSID value as int and not as a String, say for example, JMS return me the String "UTF8" when I call getStringProperty() while I need the value 1208 (either as String or int) to set the CCSID as shown above.
I hope you get my point.
Thanks. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Mar 17, 2005 6:40 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Much easier and as I said before why reinvent the wheel.
If you cannot process the message you still do a destructive get off of queue A. The app DOES NOT construct a new message.(Waste of time and resources). The app just puts the message onto Queue B. Everything is conserved. No need to look for CCSID and all the other stuff. No loss of RFH headers and so on.
Enjoy  |
|
Back to top |
|
 |
gifs71 |
Posted: Mon Mar 21, 2005 9:59 am Post subject: |
|
|
Novice
Joined: 05 Aug 2004 Posts: 13
|
Hi,
You are right and it makes perfect sense to write the message to another queue unchanged instead of creating a new message instance and populating it with the data and other header values. I am gonna go ahead and go with it.
Just as a curiosity, is there anyway one can get to the CCSID int value in anyway? Not that I am planning to use it, but would still like to know that.
Thanks. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Mar 21, 2005 12:11 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Have you tried the method: public int getInt(String mypropertyname)?
Enjoy  |
|
Back to top |
|
 |
vennela |
Posted: Mon Mar 21, 2005 12:41 pm Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
fjb_saper wrote: |
If it is to set the CCSID you have to do this through JNDI.
It is set as default at queue level and causes all messages put to that queue to have that CCSID.
Enjoy  |
One way to set it is like it is mentioned above |
|
Back to top |
|
 |
gifs71 |
Posted: Mon Mar 21, 2005 1:41 pm Post subject: |
|
|
Novice
Joined: 05 Aug 2004 Posts: 13
|
gifs71 wrote: |
Hi,
When I do a getStringProperty("JMS_IBM_Character_Set") on a Message object instance I get the character set as a string description, say UTF8, instead of the integer 1208. Performing a getIntProperty("JMS_IBM_Character_Set") gives a NumberFormatException. It is obvious that the character set property is stored as a String rather than a integer. In case of base MQ Java API the character set was represented by an integer value.
The question is how do I get the int value using the JMS API?
Thanks. |
As above, getIntProperty() does not work. |
|
Back to top |
|
 |
gifs71 |
Posted: Mon Mar 21, 2005 1:45 pm Post subject: |
|
|
Novice
Joined: 05 Aug 2004 Posts: 13
|
vennela wrote: |
fjb_saper wrote: |
If it is to set the CCSID you have to do this through JNDI.
It is set as default at queue level and causes all messages put to that queue to have that CCSID.
Enjoy  |
One way to set it is like it is mentioned above |
I am not using JNDI.
Can't set it as default at Q level as that Q can have msgs with varying CCSID values. |
|
Back to top |
|
 |
vennela |
Posted: Mon Mar 21, 2005 8:47 pm Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
Even if you use JMS URIs you can set the CCSID.
For each message you can set it differently.
JMS URI looks like this
///RECEIVER.DATA.QUEUE?CCSID=37&targetClient=1
You can build it in your app.
Before creating the QueueSender object, if you know what CCSID the message is going to be, you can build the queue URI and then do whatever you want. |
|
Back to top |
|
 |
|