简体   繁体   English

在关闭和断开IBM MQ.NET客户端上设置超时

[英]Setting Timeout on Close and Disconnect IBM MQ.NET Client

Is it possible to set timeout period for the code below: 是否可以为以下代码设置超时期限:

private MQQueueManager queueManager;
private MQQueue queue;

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

The reason is that sometimes the connection get stuck trying to close. 原因是有时尝试关闭连接时会卡住。 The thread blocked on Close() or Disconnect(). 线程在Close()或Disconnect()上阻塞。

Update 更新

The client uses managed client, CCDT file, cluster queue manager and other features that might result in different settings. 客户端使用托管客户端,CCDT文件,群集队列管理器和其他功能可能导致不同的设置。

Please provide code sample. 请提供代码示例。

Can we change the timeout setting using similar method via APIs like below: 我们可以通过类似的API使用类似的方法来更改超时设置吗,如下所示:

    int openOptions = Set possible settings here

    var properties = new Hashtable
    {
          Set possible settings here
    };

    _queueManager = new MQQueueManager(_queueManagerName, properties);
    _queue = _queueManager.AccessQueue(QUEUE_NAME, openOptions);

The way the MQ client and MQ server decide to TIMEOUT a connection is based on the negotiated Heart Beat ( HBINT ) value for the running SVRCONN channel. MQ客户端和MQ服务器决定连接超时的方式基于正在运行的SVRCONN通道的协商的心跳( HBINT )值。 The negotiated HBINT is always the highest value negotiated between the SVRCONN and the client application. 协商的HBINT始终是SVRCONN与客户端应用程序之间协商的最高值。

Note: SVRCONN HBINT has a default value of 300 . 注意: SVRCONN HBINT的默认值为300

The TIMEOUT is determined in one of two ways: 超时是通过以下两种方法之一确定的:

  1. If the negotiated HBINT is less than 60 the TIMEOUT is 2x HBINT . 如果协商的HBINT小于60,则TIMEOUT是2x HBINT
  2. If the negotiated HBINT is greater than or equal to 60 the TIMEOUT is HBINT + 60. 如果协商的HBINT大于或等于60,则TIMEOUT为HBINT + 60。

Specific to the area of .NET clients related to HBINT : 特定于与HBINT相关的.NET客户端HBINT

APAR IT26614 corrects the following three issues: APAR IT26614纠正了以下三个问题:

  1. In either Unmanaged or Managed mode it is documented that if you are not using a CCDT the HBINT will use the value of the SVRCONN channel. 在非托管或托管模式下,都有文件记录,如果您不使用CCDT,则HBINT将使用SVRCONN通道的值。 In reality if not using a CCDT the HBINT on the client side defaults to 300 so this is the lowest HBINT you will see. 实际上,如果不使用CCDT,则客户端的HBINT默认为300因此这是您将看到的最低的HBINT

  2. Specific to Managed .NET the client side HBINT cannot be lower than the SVRCONN HBINT the connection will fail with a 2059. This problem impacts both with or without CCDT. 特定于托管.NET的客户端HBINT不能低于SVRCONN HBINT ,连接将失败并显示HBINT无论是否使用CCDT,此问题都会影响。

    • with a CCDT you are unable to set the CLNTCONN HBINT to a value less than the SVRCONN HBINT 使用CCDT时,无法将CLNTCONN HBINT设置为小于SVRCONN HBINT的值
    • without a CCDT you will be impacted if the SVRCONN HBINT is set to 301 or higher 没有CCDT如果你将受到影响SVRCONN HBINT设置为301或更高
  3. Specific to Managed .NET the client side receive timeout was being calculated in milliseconds not seconds. 特定于Managed .NET,客户端接收超时的计算以毫秒为单位,而不是秒。 In this case the defect has been present according to IBM for a long time, but did not present itself until APAR IT16167: Managed .NET client application does not send heartbeat request to queue manager was introduced in 8.0.0.10 and 9.0.0.4 (IBM also confirmed this is present in GA 9.1.0.0). 在这种情况下,根据IBM长期存在该缺陷,但直到APAR IT16167才发现该缺陷:在8.0.0.10和9.0.0.4中引入了托管的.NET客户端应用程序不向队列管理器发送心跳请求 (IBM还确认GA 9.1.0.0中存在此内容)。 The reason it was not previously a problem was that Managed .NET was never initiating the Heart Beat, the queue manager would always send the Heart Beat at HBINT + 5 seconds and the .NET client would respond. 以前不是问题的原因是Managed .NET从未启动过心跳,队列管理器总是在HB​​INT + 5秒时发送心跳,.NET客户端会响应。 Once this was corrected, the miscalculation of the receive timeout presented itself. 一旦更正了该错误,就会出现接收超时的错误计算。

 The fix is targeted for delivery in the following PTFs: Version Maintenance Level v8.0 8.0.0.13 v9.0 LTS 9.0.0.7 v9.1 CD 9.1.3 v9.1 LTS 9.1.0.3 

As of July 12th 2019 only 9.0.0.7 and 9.1.3 have been released and can be downloaded from the following locations: 截至2019年7月12日,仅9.0.0.7和9.1.3已发布,可以从以下位置下载:


Unless you are using a version of the amqmdnet.dll which includes the above APAR or you ask IBM to provide you with a IFIX for any lower version, the only way to accomplish a lower than 300 HBINT would require the SVRCONN HBINT to be set to a lower value in combination with the client using a CCDT with the CLNTCONN HBINT set to a lower value. 除非您使用包含上述APAR的amqmdnet.dll版本,或者您要求IBM为任何较低版本提供IFIX,否则,实现低于300 HBINT的唯一方法是将SVRCONN HBINT设置为结合使用使用CCDT并将CLNTCONN HBINT设置为较低值的客户端的较低值。 Based on unmanaged or Managed .NET you have two options: 基于非托管或托管.NET,您有两个选择:

  1. With unmanaged .NET you can set the CLNTCONN HBINT to 1 and allow the client to to always negotiate up to the SVRCONN HBINT value. 使用非托管.NET,可以将CLNTCONN HBINT设置为1并允许客户端始终协商最高SVRCONN HBINT值。 You would then need the MQ admin to set the SVRCONN HBINT to the desired value. 然后,您将需要MQ管理员将SVRCONN HBINT设置为所需的值。
  2. With Managed .NET you would need the MQ admin to set the SVRCONN HBINT to the desired value, and you would then need to set the CCDT CLNTCONN HBINT to the same value as the SVRCONN HBINT . 使用Managed .NET,您需要MQ管理员将SVRCONN HBINT设置为所需的值,然后需要将CCDT CLNTCONN HBINT设置为与SVRCONN HBINT相同的值。

If you are using a version of the amqmdnet.dll which includes the above APAR or you ask IBM to provide you with a IFIX for any lower version the following will be how things work: 如果您正在使用包含上述APAR的amqmdnet.dll版本,或者要求IBM为您提供任何较低版本的IFIX,则将以下列方式工作:

  1. If not using a CCDT the client side will use the equivalent of HBINT(1) and will negotiate up to the SVRCONN value. 如果不使用CCDT,则客户端将使用HBINT(1)的等效项,并将协商直至SVRCONN值。
  2. If using a CCDT the CLNTCONN can have the HBINT set to 1 which would result in the same behavior as above when not using a CCDT, the HBINT will negotiate up to the SVRCONN value. 如果使用CCDT,则CLNTCONN可以将HBINT设置为1 ,这将导致不使用CCDT时具有与上述相同的行为, HBINT将协商达到SVRCONN值。

No matter if using a CCDT with CLNTCONN HBINT set to 1 or not using a CCDT where client side will use HBINT(1) , you will need to ask the MQ admin to set the SVRCONN HBINT to a lower value to accomplish a shorter TIMEOUT. 无论是使用CLNTCONN HBINT设置为1的CCDT还是不使用客户端将使用HBINT(1)的CCDT,您都需要让MQ管理员将SVRCONN HBINT设置为一个较小的值,以缩短超时时间。


Example of setting HBINT on the CCDT CLNTCONN channel: 在CCDT CLNTCONN通道上设置HBINT示例:

DEFINE CHL(CLIENT_CHL) CHLTYPE(CLNTCONN) CONNAME('1.2.3.4(9999)') QMNAME(ABC) HBINT(1)

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

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