如何使用SetBytesProperty和GetBytesProperty WebSphere MQ中? [英] How to use SetBytesProperty and GetBytesProperty in WebSphere MQ?

查看:297
本文介绍了如何使用SetBytesProperty和GetBytesProperty WebSphere MQ中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 SetBytesProperty / GetBytesProperty 方法对上 MQMessage 类(我使用WebSphere MQ客户端7.0.1.6)。我可以成功发送为sbyte 数组中的属性来排队,但一旦我设法得到它回来读消息我总是

I have a problem with SetBytesProperty / GetBytesProperty methods pair on MQMessage class (I'm using WebSphere MQ Client 7.0.1.6). I can successfully send sbyte array in property to queue but once I try to get it back in read message I always get null.

下面是最简单的code我用它来重现问题。

Here is the simplest code I use to reproduce the issue.

[TestFixture]
public class MQQueueTests {

    public const string MessageContent = "<test>This is test message</test>";

    [Test]
    public void PutAndGetMessage() {
        Environment.SetEnvironmentVariable("MQCCSID", "437");
        var properties = new Hashtable
                             {
                                 {MQC.HOST_NAME_PROPERTY, "TestServer"},
                                 {MQC.CHANNEL_PROPERTY, "Test.Channel"},
                                 {MQC.PORT_PROPERTY, 1415} 
                             };

        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.SetBytesProperty("testBytesValue", 
                   new sbyte[] { 8, 12, 22, 48, 68, 71, 92, 104 });
                message.WriteUTF(MessageContent);
                queue.Put(message);

                MQMessage readMessage = new MQMessage();
                queue.Get(readMessage);

                sbyte[] array = readMessage.GetBytesProperty("testBytesValue");
                Assert.IsNotNull(array);  // <-- FAILS!

                Assert.AreEqual(MessageContent, readMessage.ReadUTF());

                queue.Close();
            }
            manager.Disconnect();
        }
    }
}

东西传入消息属性排队 - 我可以看到服务器上的东西在WebSphere MQ资源管理,但它并不像我传递的数组(在收到新邮件时,随着时间的推移它甚至改变):

Something is passed in message property to queue - I can see something in WebSphere MQ Explorer on the server but it doesn't look like my passed array (it even change over time when new messages are received):

当我打开跟踪( strmqtrc )的MQ客户端,我可以看到相同的值,写和客户端阅读:

When I turn on tracing (strmqtrc) on MQ Client I can see the same value wrote and read by the client:

这是present日志时,将消息发送到队列:

This is present in log when putting message to the queue:

Data:-
 0x00000000 026B5878 3C 75 73 72 3E 3C 74 65 73 74 42 79 74 65 73 56 : <usr><testBytesV
 0x00000000 026B5888 61 6C 75 65 20 64 74 3D 22 62 69 6E 2E 68 65 78 : alue dt="bin.hex
 0x00000000 026B5898 22 20 3E 30 38 30 63 31 36 33 30 34 34 34 37 35 : " >080c163044475
 0x00000000 026B58A8 63 36 38 3C 2F 74 65 73 74 42 79 74 65 73 56 61 : c68</testBytesVa
 0x00000000 026B58B8 6C 75 65 3E 3C 2F 75 73 72 3E 20 20             : lue></usr>  

这是present日志时,从队列中获取消息(我删除了一些数据,使之短,但显著的部分是完全一样的日志):

This is present in log when getting message from the queue (I removed some data to make it shorter but significant part is exactly as in log):

Receiving Data:-

 0x00000000 1D2A5090 20 20 20 20 20 20 20 20 00 00 00 00 B8 04 00 00 :         ....¸...
 0x00000000 1D2A50A0 4C 00 00 00 3C 75 73 72 3E 3C 74 65 73 74 42 79 : L...<usr><testBy
 0x00000000 1D2A50B0 74 65 73 56 61 6C 75 65 20 64 74 3D 22 62 69 6E : tesValue dt="bin
 0x00000000 1D2A50C0 2E 68 65 78 22 20 3E 30 38 30 63 31 36 33 30 34 : .hex" >080c16304
 0x00000000 1D2A50D0 34 34 37 35 63 36 38 3C 2F 74 65 73 74 42 79 74 : 4475c68</testByt
 0x00000000 1D2A50E0 65 73 56 61 6C 75 65 3E 3C 2F 75 73 72 3E 20 20 : esValue></usr>  
 0x00000000 1D2A50F0 00 21 3C 74 65 73 74 3E 54 68 69 73 20 69 73 20 : .!<test>This is 
 0x00000000 1D2A5100 74 65 73 74 20 6D 65 73 73 61 67 65 3C 2F 74 65 : test message</te
 0x00000000 1D2A5110 73 74 3E 34 54 53 48 4D 00 00 00 34 00 00 00 01 : st>4TSHM...4....

因此​​,在发送和接收我看到同样正确的字节数组。但是,在.NET code中的属性值

每隔 GetXXXProperty SetXXXProperty 方法,对工作没有任何问题。

Every other GetXXXProperty and SetXXXProperty method pair works without any problem.

编辑:

我证实,它不运行WebSphere MQ客户端的同一版本的多个计算机上工作,我也验证了它不与其它code工作。它的工作原理,如果我重写测试Java和使用Java API,而不是!

I validated that it doesn't work on multiple computers running same version of WebSphere MQ clients and I also validated that it doesn't work with another code. It works if I rewrite the test to Java and use Java API instead!

我也有问题,发送的信息有针对性地 MQTopic 的任何财产 - 我得到的MQException:MRQC_HEADER_ERROR 。此外它工作在Java中没有问题。

I also have problems with sending any property in message targeted to MQTopic - I get MQException : MRQC_HEADER_ERROR. Again it works in Java without problem.

推荐答案

我能够获得的价值。我可以看到返回的数组有相同值的那些发送的消息中。这里是C#代码段我用了。

I am able to get the value. I can see the returned array has the same values as the ones in the sent message. Here is the C# snippet I used.

                MQMessage message = new MQMessage();
                message.SetBytesProperty("testBytesValue", new sbyte[] { 8, 12, 22, 48, 68, 71, 92, 104 });
                message.WriteUTF(MessageContent);
                queue.Put(message);

                MQMessage readMessage = new MQMessage();
                queue.Get(readMessage);

                sbyte[] array = readMessage.GetBytesProperty("testBytesValue");
                Console.Write(array);

这篇关于如何使用SetBytesProperty和GetBytesProperty WebSphere MQ中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆