简体   繁体   English

IBM Websphere MQ Latency用于存储持久消息.NET客户端

[英]IBM Websphere MQ Latency for storing persistent messages .NET client

When MQ server receives Put() request, what factors are affecting when messages are stored? 当MQ服务器收到Put()请求时,什么因素会影响消息存储的时间? Below is potential factors: 以下是潜在因素:

1) caching messages in memory for some times, or 1)将消息在内存中缓存一段时间,或者

2) when certain number of messages are received 2)当收到一定数量的消息时

3) When certain byte threshold of messages are received 3)收到消息的特定字节阈值时

4) MQ server save it IMMEDIATELY for each message. 4)MQ服务器为每个消息立即将其保存。

UPDATE 更新

That is, when Put() returns, has messages been saved to hard disk, or in cache depending on factors above? 也就是说,当Put()返回时,是否已根据上述因素将邮件保存到硬盘或缓存中?

Any information and links to official doc would be great appreciated. 任何信息和官方文档的链接将不胜感激。

Below is a simple scenario where Put() is used. 以下是使用Put()的简单方案。

     void PutMessages()
    {
         Open(ConnectionMode.Write);

            // putting messages continuously
            for (int i = 1; i <= numberOfMsgs; i++)
            {
                PutMessage(GetMessageInBytes(i));
            }

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

    void PutMessage(byte[] messageString)
    {

        // creating a message object
        message = new MQMessage();
        message.Write(messageString);
        message.Format = MQC.MQFMT_STRING;
        message.CharacterSet = 1208;// IbmUtf8Encoding;
        message.Persistence = MQC.MQPER_PERSISTENT;

        var options = new MQPutMessageOptions
        {
            Options = false ? MQC.MQPMO_SYNCPOINT : MQC.MQPMO_NO_SYNCPOINT
        };

        queue.Put(message, options);            

    }

    public void Open(ConnectionMode connectionMode)
    {
        var connectionSettings = new Hashtable
        {
            {MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED },
            {MQC.CONNECT_OPTIONS_PROPERTY, MQC.MQCNO_RECONNECT }
        };

        int openOptions = 0;

        switch (connectionMode)
        {
            case ConnectionMode.Read:
                openOptions = MQC.MQOO_INPUT_SHARED + MQC.MQOO_FAIL_IF_QUIESCING;
                break;
            case ConnectionMode.Write:
                openOptions = MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING;
                break;
        }
        queueManager = new MQQueueManager(queueManagerName);
        queue = queueManager.AccessQueue(queueName, openOptions);
    }


    public enum ConnectionMode
    {
        Read,
        Write
    }

In the IBM MQ v9 Knowledge center page " Application design and performance considerations " it has this two say: 在IBM MQ v9知识中心页面“ 应用程序设计和性能注意事项 ”中,有两个说法:

Put persistent messages under syncpoint 将持久性消息置于同步点下

Persistent messages should be put and got under syncpoint. 持久消息应放在同步点下。 This is because when getting a persistent message outside of syncpoint, if the get fails, there is no way for the application to know whether the message has been got from the queue or not, and whether, if the message has been got, then it has also been lost. 这是因为在同步点之外获取持久消息时,如果获取失败,则应用程序无法知道是否已从队列中获取消息,以及是否已获取消息,则无法知道该消息。也已经迷路了。 When getting persistent messages under syncpoint, if anything fails, the transaction is rolled back and the persistent message is not lost because it is still on the queue. 在同步点下获取持久消息时,如果发生任何故障,则事务将回滚,并且持久消息不会丢失,因为它仍在队列中。 Similarly, when putting persistent messages, put them under syncpoint. 同样,在放置持久消息时,请将其置于同步点下。 Another reason for putting and getting persistent messages under syncpoint is that the persistent message code in IBM MQ is heavily optimized for syncpoint. 将持久性消息放入和获取同步点的另一个原因是,IBM MQ中的持久性消息代码已针对同步点进行了优化。 So putting and getting persistent messages under syncpoint is faster than putting and getting persistent messages outside of syncpoint. 因此,将持久性消息放入并同步点比将同步消息放入并同步点要快。

However, it is faster to put and get non-persistent messages outside of syncpoint because the nonpersistent code in IBM MQ is optimized for being outside of syncpoint. 但是,将非持久消息放入和获取到同步点之外更快,因为IBM MQ中的非持久代码已针对同步点之外进行了优化。 Putting and getting persistent messages go at disk speeds because the persistent message is persisted to disk. 放置和获取持久性消息的速度磁盘一样快, 因为持久性消息被持久化到磁盘上。 However, putting and getting non-persistent messages go at CPU speeds because there is no disk write involved, not even when using syncpoint. 但是,放置和获取非持久消息会以CPU速度运行,因为不涉及磁盘写入,甚至在使用同步点时也是如此。

If an application is getting messages and does not know in advance whether they are persistent or not, the GMO option MQGMO_SYNCPOINT_IF_PERSISTENT can be used. 如果应用程序正在获取消息,并且事先不知道消息是否持久,则可以使用GMO选项MQGMO_SYNCPOINT_IF_PERSISTENT。


Chris Frank from IBM gave a presentation at Capitalware's MQ Technical Conference v2.0.1.6 titled More Mysteries of the IBM MQ Distributed Logger , Slide "What if I Don't Use Transactions? (2)" on Page 87 states: IBM的Chris Frank在Capitalware的MQ技术会议v2.0.1.6上作了题为“ IBM MQ分布式记录器的更多奥秘”的演讲,第87页的幻灯片“如果我不使用交易该怎么办?(2)”指出:

  • Contrast this with not using Syncpoint: 与不使用Syncpoint进行对比:
    • Each MQPut will result in at least one physical write to the log file 每个MQPut将至少对日志文件进行一次物理写入
      • The putting application will be blocked during this time 在此期间,推杆应用程序将被阻止

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM