I'm currently developing an application which needs to connect a MQ Queue in order to have the queue saving message information inside another service. Once it's done, the service returns a result message through the MQ Queue and it is returned to me.
I'm sending a string message that contains a XML message similar to the following one:
<?xml version="1.0" encoding="UTF-8"?>
<peticionDemanda>
<subtipo>DEMANDA CONTRATACIÓN</subtipo>
</peticionDemanda>
It appears that MQ is not decoding properly the "Ó" character and "subtipo" field is being saved as "DEMANDA CONTRATACI├ôN".
I'm encoding the message in "UTF-8" and I've been told that the CCSID I'm using to send the message is 850 instead of 1208 (the one belonging to UTF-8).
To run the MQ manager, I'm using "pymqi" Python library in Client Mode. This is the MQManager class I use to send messages to the queue and get the response:
class MQManager:
def __init__(self):
self.queue_manager = config.queue_manager
self.channel = config.channel
self.port = config.port
self.host = config.host
self.conn_info = config.conn_info
self.queue_request_name = config.queue_request_name
self.queue_response_name = config.queue_response_name
cd = pymqi.CD()
cd.ChannelName = self.channel
cd.ConnectionName = self.conn_info
cd.ChannelType = pymqi.CMQC.MQCHT_CLNTCONN
cd.TransportType = pymqi.CMQC.MQXPT_TCP
self.qmgr = pymqi.QueueManager(None)
self.qmgr.connect_with_options(self.queue_manager, opts=pymqi.CMQC.MQCNO_HANDLE_SHARE_NO_BLOCK, cd=cd)
def send_message(self, str_xml_message):
# set message descriptor
request_md = pymqi.MD()
request_md.ReplyToQ = self.queue_response_name
request_md.Format = pymqi.CMQC.MQFMT_STRING
queue_request = pymqi.Queue(self.qmgr, self.queue_request_name)
queue_request.put(str_xml_message.encode("UTF-8"), request_md)
queue_request.close()
# Set up message descriptor for get.
response_md = pymqi.MD()
response_md['CorrelId'] = request_md['MsgId']
gmo = pymqi.GMO()
gmo.Options = pymqi.CMQC.MQGMO_WAIT | pymqi.CMQC.MQGMO_FAIL_IF_QUIESCING
gmo.WaitInterval = 5000 # 5 seconds
queue_response = pymqi.Queue(self.qmgr, self.queue_response_name)
message = queue_response.get_no_rfh2(None, response_md, gmo)
queue_response.close()
return str(message)
def close(self):
self.qmgr.disconnect()
I wonder how can I define the MQ Manager's CCSID value and hopefully solve the codepage mismatch.
Thank you!