IBM XMS Receive 方法不立即返回消息

IBM XMS Receive method not returning messages immediately

我使用 IBM XMS 连接到第三方来发送和接收消息。

更新:


我已经使用超时接收有一段时间了,没有出现问题,但自上周以来,我开始看不到任何消息可供选择 - 即使它们在那里 - 但一旦我更改为非超时接收方法,我就开始了再次选择每 5 分钟一次的消息。

查看 XMS 日志,我可以看到消息实际上几乎是立即读取的,有和没有超时,但 XMS 似乎决定等待这 5 分钟再返回消息...

我这边没有任何改变,第三方也保证他们也没有改变。

我的问题是:鉴于以下用于接收的代码,是否有任何可能导致 5 分钟等待的原因?关于我可以尝试的事情有什么想法吗?如果有帮助,我也可以分享 XMS 日志。

// This is used to set the default properties in the factory before calling the receive method
        private void SetConnectionProperties(IConnectionFactory cf)
        {
            cf.SetStringProperty(XMSC.WMQ_HOST_NAME, _mqConfiguration.Host);
            cf.SetIntProperty(XMSC.WMQ_PORT, _mqConfiguration.Port);
            cf.SetStringProperty(XMSC.WMQ_CHANNEL, _mqConfiguration.Channel);
            cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, _mqConfiguration.QueueManager);
            cf.SetStringProperty(XMSC.WMQ_SSL_CLIENT_CERT_LABEL, _mqConfiguration.CertificateLabel);
            cf.SetStringProperty(XMSC.WMQ_SSL_KEY_REPOSITORY, _mqConfiguration.KeyRepository);
            cf.SetStringProperty(XMSC.WMQ_SSL_CIPHER_SPEC, _mqConfiguration.CipherSuite);

            cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
            cf.SetIntProperty(XMSC.WMQ_CLIENT_RECONNECT_OPTIONS, XMSC.WMQ_CLIENT_RECONNECT);
            cf.SetIntProperty(XMSC.WMQ_CLIENT_RECONNECT_TIMEOUT, XMSC.WMQ_CLIENT_RECONNECT_TIMEOUT_DEFAULT);
        }
        
        public IEnumerable<IMessage> ReceiveMessage()
        {
            using var connection = _connectionFactory.CreateConnection();
            using var session = connection.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
            using var destination = session.CreateQueue(_mqConfiguration.ReceiveQueue);
            using var consumer = session.CreateConsumer(destination);

            connection.Start();

            var result = new List<IMessage>();
            var keepRunning = true;
            while (keepRunning)
            {
                try
                {
                    var sw = new Stopwatch();
                    sw.Start();

                    var message = _mqConfiguration.ConsumerTimeoutMs == 0 ? consumer.Receive() 
                        : consumer.Receive(_mqConfiguration.ConsumerTimeoutMs);

                    if (message != null)
                    {
                        result.Add(message);
                        _messageLogger.LogInMessage(message);
                        var ellapsedMillis = sw.ElapsedMilliseconds;
                        if (_mqConfiguration.ConsumerTimeoutMs == 0)
                        {
                            keepRunning = false;
                        }
                    }
                    else
                    {
                        keepRunning = false;
                    }
                }
                catch (Exception e)
                {
                    // We log the exception
                    keepRunning = false;
                }
            }

            consumer.Close();
            destination.Dispose();
            session.Dispose();
            connection.Close();

            return result;
        }

症状看起来与 APAR IJ20591: Managed .NET SSL application making MQGET calls unexpectedly receives MQRC_CONNECTION_BROKEN when running in .NET Core. This impacts messages larger than 15kb and IBM MQ .net standard (core) libraries using TLS channels. See also this thread 匹配。这将在 9.2.0.5 中修复,未列出 CDS 版本。

它指出:

Setting the heartbeat interval to lower values may reduce the frequency of occurrence.

如果您的 .NET 应用程序未使用 CCDT,您可以通过降低 SVRCONN 通道的 HBINT 并重新连接您的应用程序来降低检测信号。