0

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

更新:

  • 客户端.Net Core 3.1
  • 来自 Nuget 的 IBM XMS 库版本。尝试了 9.2.4 和 9.1.5,结果相同
  • 一周前使用相同的代码可以正常工作 - 所以 MQ 管理器或我的基础架构中的某个地方一定发生了变化
  • SSL 和客户端证书

我一直在使用超时接收没有问题,但从上周开始,我开始看不到任何要选择的消息 - 即使它们在那里 - 但是一旦我更改为非超时接收方法,我再次开始每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;
        }
4

1 回答 1

1

症状看起来与 APAR IJ20591 匹配:在 .NET Core 中运行时,进行 MQGET 调用的托管 .NET SSL 应用程序意外收到 MQRC_CONNECTION_BROKEN。这会影响大于 15kb 的消息和使用 TLS 通道的 IBM MQ .net 标准(核心)库。另请参阅此线程。这将在 9.2.0.5 中修复,没有列出 CDS 版本。

它指出:

将心跳间隔设置为较低的值可能会降低发生频率。

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

于 2022-01-13T19:17:34.913 回答