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 » JAVA JMS SPRING CCSID for Japanese Character 1399 & 5026

Post new topic  Reply to topic
 JAVA JMS SPRING CCSID for Japanese Character 1399 & 5026 « View previous topic :: View next topic » 
Author Message
sponnaz
PostPosted: Sun Mar 11, 2018 10:31 pm    Post subject: JAVA JMS SPRING CCSID for Japanese Character 1399 & 5026 Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Mon Mar 12, 2018 2:49 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20695
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
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
sponnaz
PostPosted: Mon Mar 12, 2018 9:55 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Mon Mar 12, 2018 2:20 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20695
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.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
rekarm01
PostPosted: Sat Mar 17, 2018 6:24 pm    Post subject: Re: JAVA JMS SPRING CCSID for Japanese Character 1399 & Reply with quote

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
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 » JAVA JMS SPRING CCSID for Japanese Character 1399 & 5026
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.