|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
![Reply to topic](templates/DAJ_Glass/images/lang_english/reply.gif) |
|
JAVA JMS SPRING CCSID for Japanese Character 1399 & 5026 |
« View previous topic :: View next topic » |
Author |
Message
|
sponnaz |
Posted: Sun Mar 11, 2018 10:31 pm Post subject: JAVA JMS SPRING CCSID for Japanese Character 1399 & 5026 |
|
|
Newbie
Joined: 11 Mar 2018 Posts: 2
|
Current System:
MQ7 & Message Broker running on same AIX server,QMGR - CCSID - 819/1028(UTF8) routes message with Japanese Character message format with CCSID 1399 to Mainframe QMGR CCSID 37. Message delivered in the same encoding as receiver(mainframe CICS program) expects.
Code Snippet from Broker
SET OutputRoot.MQMD.Format = MQFMT_STRING;
SET OutputRoot.MQMD.CodedCharSetId = 1399;
SET OutputRoot.Properties.CodedCharSetId = 1399;
New Proposed Sytem
Broker is replaced by Java/SPRINGBoot on Linux, which uses the same route AIX QMGR(CCSID 819/1028) to Mainframe.
Issue: JVM on Linux is not finding 1399 CCSID, getting unsupported encoding error. Does OS locale or JVM configuration need to be modified support 1399 CCSID?
bytes.writeBytes(txt.getBytes((CCSID.getCodepage(1399))));
As a workaround tried CCSID 5026 assuming its compatible format for 1399.
JVM was able to write bytes in 5026 CCSID(x-IBM930), however when inspected through an utility, CCSID in Message header still shows 1208(UTF8).
Here's the code snippet
String senderQ = "queue:///"+queueName+"?CCSID=5026&targetClient=1";
jmsTemplate.send(senderQ,new MessageCreator() {
bytes.setStringProperty(WMQConstants.JMS_IBM_FORMAT, "MQSTR"); bytes.setIntProperty(WMQConstants.JMS_IBM_CHARACTER_SET,ccsid);
bytes.writeBytes(txt.getBytes((CCSID.getCodepage(ccsid))));
}
Destination CCSID is overridden in the URL, JMS_IBM_CHARACTER_SET to 5026.
Message Header:
Encoding : 273 CodedCharSetId : 819 Format : 'MQSTR '
Is QMGR overriding CCSID ? What needs to be done to retain the client formatted CCSID.
Also noticed that when JMS_IBM_FORMAT, "MQSTR" is not set, then CodedCharSetId is 930(which is the base encoding of CCSID 5026), however receiving destination rejects these message due to invalid format.
Encoding : 273 CodedCharSetId : 930 Format : ' '
Why QMGR set different CCSID based on JMS_IBM_FORMAT?
I've searched this forum and googled, but not found any solution, any help is
greatly appreciated.
Thanks,
Sam. |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
fjb_saper |
Posted: Mon Mar 12, 2018 2:49 am Post subject: |
|
|
![](images/avatars/gallery/misc/2.gif) Grand High Poobah
Joined: 18 Nov 2003 Posts: 20696 Location: LI,NY
|
Hi Sam,
Your message creator is all wrong.
You need to do the following
Code: |
Message msg = session.CreateTextMessage();
Destination dest = session.CreateQueue(senderQ);
msg.setText(yourtext_String);
Producer prod = session.CreateProducer(dest);
prod.send(msg); |
Have fun ![](images/smiles/innocent.gif) _________________ MQ & Broker admin |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
sponnaz |
Posted: Mon Mar 12, 2018 9:55 am Post subject: |
|
|
Newbie
Joined: 11 Mar 2018 Posts: 2
|
My Apologies for not providing the full code.
My message creator uses createBytesMessage() and here am using jmsTemplate.send(DestinationName,Message) so whatever properties set inside destination object through create queue will be overridden by Spring jmsteamplat.send which inturn uses resolveDestinationName(session, destinationName) to create destination hence used queue URL pattern to set CCSID of destination object. charSetId is set to 5026 & mqQueueConnectionFactory.setCCSID(5026);
Code: |
public void sendMessageJP(JmsTemplate jmsTemplate,final String txt,String queueName,int charSetId) throws JMSException{
String senderQ ="queue:///"+queueName+"?CCSID=5026&targetClient=1";
jmsTemplate.setExplicitQosEnabled(true);
jmsTemplate.setDeliveryPersistent(false);
jmsTemplate.send(senderQ,new MessageCreator() {
public javax.jms.Message createMessage(javax.jms.Session session) throws JMSException {
BytesMessage bytes = session.createBytesMessage();
bytes.setStringProperty(WMQConstants.JMS_IBM_FORMAT, "MQSTR");
bytes.setIntProperty(WMQConstants.JMS_IBM_CHARACTER_SET,charSetId);
try {
/*
Destination destination = session.createQueue(senderQ);
bytes.writeBytes(txt.getBytes(
CCSID.getCodepage(((MQDestination) destination)
.getIntProperty(WMQConstants.WMQ_CCSID))));*/
bytes.writeBytes(txt.getBytes((CCSID.getCodepage(charSetId))));
} catch (Exception e) {
LOGGER.error(errorLog.getErrorDetail(e), e);
}
return bytes;
}
}); |
Thanks,
Sam. |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
fjb_saper |
Posted: Mon Mar 12, 2018 2:20 pm Post subject: |
|
|
![](images/avatars/gallery/misc/2.gif) Grand High Poobah
Joined: 18 Nov 2003 Posts: 20696 Location: LI,NY
|
Well Sam you're potentially shooting yourself into the foot, or at least making it much more complicated...
When setting MQFMT_STRING, you should really create a TextMessage and pass it a String. This way you only have to set the CCSID on the destination and don't have to worry about the conversion of the bytes into the correct CCSID.
Hope it helps. ![](images/smiles/innocent.gif) _________________ MQ & Broker admin |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
rekarm01 |
Posted: Sat Mar 17, 2018 6:24 pm Post subject: Re: JAVA JMS SPRING CCSID for Japanese Character 1399 & |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
sponnaz wrote: |
Current System:
MQ7 & Message Broker running on same AIX server,QMGR - CCSID - 819/1028(UTF8) |
MQ 7.what? Which is the qmgr ccsid? 819? 1028? Or should that be 1208?
sponnaz wrote: |
Issue: JVM on Linux is not finding 1399 CCSID, getting unsupported encoding error. Does OS locale or JVM configuration need to be modified support 1399 CCSID?
Code: |
bytes.writeBytes(txt.getBytes((CCSID.getCodepage(1399)))); |
|
It's better to have too many parentheses, rather than not enough, right?
The CCSID.getCCSIDs() method should return a list of supported ccsids.
sponnaz wrote: |
Why QMGR set different CCSID based on JMS_IBM_FORMAT? |
It could be that for MQFMT_STRING, JMS wants to convert a BytesMessage to a TextMessage, but the send() method uses a different ccsid to convert it back to bytes again, before putting it on a queue.
But that's just a guess. |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
|
|
![Reply to topic](templates/DAJ_Glass/images/lang_english/reply.gif) |
|
Page 1 of 1 |
|
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
|
|
|
|