We are using IBM MQ with Microfocus Cobol (Enterprise Developer) and, alternatively, python (via the pymqi module) on Red Hat linux.
Our messages contain binary data and are single byte coded – since we are migrating from an ebcdic environment we have switched to Latin-1 (from copdepage 1141 to 819 to be precise).
I’m using Python (pymqi) and I’m trying to MQPUT a single byte character message as binary data from disc after decoding it to Latin-1 but IBM MQ ignores my plea for a ccsid other than 1208 (UTF-8).
Messages generated by our application get the “Character Set” value of “ISO-8859-1”.
Here I’m reading a message from a file in binary mode (which is the mode I previously extracted these messages) and, after decoding it to ccsid 819, call mqput. I’ve put correct values inside the MQ message header (the MD structure) before that:
with open(filename,"rb") as f:
message = f.read()
put_md = pymqi.MD()
put_md["Encoding"] = 273
put_md["CodedCharSetId"] = 819
message_dec = message.decode("ISO-8859-1")
queue.put(message_dec, put_md)
When I look at this message via MQs rest interface the “Encoding” value is honored (shows 273) while the “Character Set” value is “UTF-8” no matter what I try. Since everything works fine when the application does it there seems to be something I’m missing from the Python point of view.
I’ve tried to set the message format to something else than MQSTR but this is being ignored as well.
Alternatively when the binary message is sent
with open(filename,"rb") as f:
message = f.read()
put_md = pymqi.MD()
put_md["Encoding"] = 273
put_md["CodedCharSetId"] = 819
queue.put(message, put_md)
I can’t read the resulting message from the REST interface because it’s flagged as binary, but the “Character Set” value is finally the way I wanted it (“ISO-8859-1”) and the “Message type” is no longer MQSTR (which means that MQ won’t convert the message under any circumstances).
Looks like the library checks whether the message to MQPUT is a binary string and reacts if not by processing it as UTF-8 (possibly even encoding it in the process… I haven’t checked, but this would be fatal because encoding our messages would probably lead to corrupt data).
I have also tried setting the MQCCSID environment variable
export MQCCSID=819
but to no avail.
This seems to be a bug in pymqi, and since I’m somewhat of a newbie in Python I don’t dare to suggest any changes to the source code.
Alas I’m not sure, because of the funny behaviour concering the message format values.
Anybody out there who has a suggestion?
2