Java MQ 最大连接数问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24653053/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 13:49:23  来源:igfitidea点击:

MQ max connections issue

javaspringjmsibm-mq

提问by Bazza

I have a Java client that connects to MQ with 10 connections. These remain open for the duration that the Java client runs. For each thread we create a message, create a session, send the message and close the session. We are using the Spring CachingConnectionFactory and have a sessionCacheSize of 100. We have been told by our MQ engineering team is that that our queue manager has a max connections of 500 and that we are exceeding this. The QM.ini file has:

我有一个 Java 客户端,它通过 10 个连接连接到 MQ。这些在 Java 客户端运行期间保持打开状态。对于每个线程,我们创建一条消息,创建一个会话,发送消息并关闭会话。我们正在使用 Spring CachingConnectionFactory 并且 sessionCacheSize 为 100。我们的 MQ 工程团队告诉我们,我们的队列管理器的最大连接数为 500,我们已经超过了这个值。QM.ini 文件具有:

maxChannels=500
maxActiveChannels=256
maxHandles=256

What I have observed in MQ explorer is that the open output count on the queue remains static at 10, however if we load balance across 2 queues it's 10 on each, even though we still only have 10 connections. So what I'd like to know is what do jms connections and sessions equate to in MQ terminology?

我在 MQ 资源管理器中观察到,队列上的打开输出计数保持静态为 10,但是如果我们跨 2 个队列进行负载平衡,则每个队列都是 10,即使我们仍然只有 10 个连接。那么我想知道的是 jms 连接和会话在 MQ 术语中等同于什么?

I did think that a connection equates to an active channel and a session is a handle, so it was the handles that we were possibly exceeding as the amount of sessions we open (and close) run into hundreds or thousands, whereas we only have 10 connections. Although going against this, the snippet below from IBM's Technote "Explanation of connection pool and session pool settings for JMS connection factories", suggests that the max channels should be greater than the max sessions, however we never know this as it depends on the load (unless this should be greater than the sessionCacheSize?).

我确实认为连接等同于活动通道而会话是句柄,因此当我们打开(和关闭)的会话数量达到数百或数千时,我们可能会超过句柄,而我们只有 10连接。尽管与此相反,IBM 的技术说明“ JMS 连接工厂的连接池和会话池设置说明”中的以下片段表明最大通道应该大于最大会话,但是我们永远不知道这一点,因为它取决于负载(除非这应该大于 sessionCacheSize?)。

Each session represents a TCP/IP connection to the queue manager. With the settings mentioned here, there can be a maximum of 100 TCP/IP connections. If you are using WebSphere MQ, it is important to tune the queue manager's MaxChannels setting, located in the qm.ini file, to a value greater than the sum of the maximum possible number of sessions from each JMS connection factory that connects to the queue manager.

每个会话代表一个到队列管理器的 TCP/IP 连接。使用此处提到的设置,最多可以有 100 个 TCP/IP 连接。如果您正在使用 WebSphere MQ,那么将位于 qm.ini 文件中的队列管理器的 MaxChannels 设置调整为一个大于连接到队列的每个 JMS 连接工厂的最大可能会话数总和的值很重要经理。

Any assistance on how best to configure MQ would be appreciated.

任何关于如何最好地配置 MQ 的帮助将不胜感激。

采纳答案by whitfiea

Assuming that your maximum number of conversations is set to 1 on the MQ Channel (the default is 10 in MQ v7 and v7.5) then a JMS Connection will result in a TCP connection (MQ channel instance) and a JMS Session will result in another TCP connection (MQ channel instance).

假设您在 MQ 通道上的最大对话数设置为 1(在 MQ v7 和 v7.5 中默认为 10),那么 JMS 连接将产生 TCP 连接(MQ 通道实例),而 JMS 会话将产生另一个 TCP 连接(MQ 通道实例)。

From your update it sounds like you have 10 JMS Connections configured and the sessionCacheSize in Spring set to 100, so 10 x 100 means 1000 potential MQ channel instances being created. The open output count will show how many 'active' JMS Sessions are attempting send a message and not necessarily how many have been 'cached'.

从您的更新来看,您似乎配置了 10 个 JMS 连接,并且 Spring 中的 sessionCacheSize 设置为 100,因此 10 x 100 意味着正在创建 1000 个潜在的 MQ 通道实例。打开的输出计数将显示有多少“活动”JMS 会话正在尝试发送消息,而不一定是“缓存”了多少。

The conversation sharing on the MQ channel might help you here as this defines how many logical connections can be shared over one TCP connection (MQ channel instance). So the default of 10 conversations means you can have 10 JMS Sessions created that operate over just one TCP connection.

MQ 通道上的对话共享在这里可能会对您有所帮助,因为它定义了可以通过一个 TCP 连接(MQ 通道实例)共享多少个逻辑连接。因此默认的 10 个会话意味着您可以创建 10 个 JMS 会话,这些会话仅在一个 TCP 连接上运行。