I have some strange problem. I think I followed documentation correctly but my code doesn’t work. I have this very simple hard coded test (NUnit):
[TestFixture]
public class MQQueueTests {
public const string MessageContent = "<test>This is test message</test>";
public static void Main(string[] args) {
var tests = new MQQueueTests();
tests.PutAndGetMessage();
}
[Test]
public void PutAndGetMessage() {
var properties = new Hashtable
{
{MQC.HOST_NAME_PROPERTY, "TestServer"},
{MQC.CHANNEL_PROPERTY, "Test.Channel"},
{MQC.PORT_PROPERTY, 1415},
// Is this correct? It looks like it is not
// enough because adding this line didn't solve
// the problem.
{MQC.CCSID_PROPERTY, 437}
};
using (var manager = new MQQueueManager("Test.Queue.Manager", properties)) {
using (MQQueue queue = manager.AccessQueue("Test.Queue",
MQC.MQOO_OUTPUT | MQC.MQOO_INPUT_AS_Q_DEF)) {
MQMessage message = new MQMessage();
message.WriteUTF(MessageContent);
queue.Put(message);
MQMessage readMessage = new MQMessage();
queue.Get(readMessage);
Assert.AreEqual(MessageContent, readMessage.ReadUTF());
queue.Close();
}
manager.Disconnect();
}
}
}
I’m running the test application either from console or through Resharper 6 test runner. If I run the application in test runner I always get following exception:
IBM.WMQ.MQException : MQRC_CHANNEL_CONFIG_ERROR (reason code is 2539)
The exception is thrown by MQQueueManager.Connect (called by its constructor).
If I check MQ logs I see:
AMQ9541: CCSID supplied for data conversion not supported.
EXPLANATION: The program ended because, either the source CCSID ‘437’
or the target CCSID ‘852’ is not valid, or is not currently supported.ACTION: Correct the CCSID that is not valid, or ensure that the
requested CCSID can be supported.
If I run the application from the console I got the same error but if I change the code page for console by calling
chcp 437
My test application works. How can I configure code page from code?
Well I found a workaround – it can probably solve my problem but I’m not very satisfied with it. I can set up
MQCCSIDenvironment variable either globally or by calling:That will configure code page. Still I would like to use properties of a new
MQQueueManagerinstance to setup code page.