简体   繁体   English

IBM MQ 消息限制

[英]IBM MQ Message Throttling

We are using IBM MQ and we are facing some serious problems regarding controlling its asynchronous delivery to its recipient.We are having some java listeners configured, now the problem is that we need to control the messages coming towards listener, because the messages coming to server are in millions count and server machine dont have that much capacity t process so many threads at a time, so is there any way like throttling on IBM MQ side where we can configure preetch limit like Apache MQ does?我们正在使用 IBM MQ,并且在控制其向接收者的异步传递方面面临一些严重问题。我们配置了一些 java 侦听器,现在问题是我们需要控制到达侦听器的消息,因为到达服务器的消息以百万计,服务器机器没有那么多容量一次处理这么多线程,那么有没有办法像在 IBM MQ 端进行节流一样,我们可以像 Apache MQ 那样配置 preetch 限制?

or is there any other way to achieve this?还是有其他方法可以实现这一目标?

Currently we are closing connection with IBM MQ when some X limit has reached on listener, but doesen't seems to be efficient way.目前,当侦听器达到某个 X 限制时,我们正在关闭与 IBM MQ 的连接,但这似乎不是一种有效的方式。

Please guys help us out to solve this issue.请大家帮我们解决这个问题。

Generally with message queueing technologies like MQ the point of the queue is that the sender is decoupled from the receiver.通常对于像 MQ 这样的消息队列技术,队列的重点是发送者与接收者分离。 If you're having trouble with message volumes then the answer is to let them queue up on the receiver queue and process them as best you can, not to throttle the sender.如果您在消息量方面遇到问题,那么答案是让它们在接收者队列中排队并尽可能地处理它们,而不是限制发送者。

The obvious answer is to limit the maximum number of threads that your listeners are allowed to take up.显而易见的答案是限制您的侦听器允许占用的最大线程数。 I'm assuming you're using some sort of MQ threadpool?我假设您正在使用某种 MQ 线程池? What platform are you using that provides unlimited listener threads?您使用什么平台提供无限的侦听器线程?

From your description, it almost sounds like you have some process running that - as soon as it detects a message in the queue - it reads the message, starts up a new thread and goes back and looks at the queue again.根据您的描述,听起来您几乎有一些进程正在运行 - 一旦它检测到队列中的消息 - 它就会读取消息,启动一个新线程并返回并再次查看队列。 This is the WRONG approach.这是错误的方法。

You should have a defined number of process threads running (start with one and scale up as required, and within limits of your server) which read from the queue themselves.您应该有一个定义数量的进程线程正在运行(从一个开始并根据需要进行扩展,并且在您的服务器的限制范围内),这些线程从队列本身中读取。 They would each open the queue in shared mode and either get-with-wait or do immediate get with a sleep if you get a MQRC 2033 (no messages in queue).如果您获得 MQRC 2033(队列中没有消息),他们每个人都会以共享模式打开队列,要么等待获取,要么立即获取睡眠。

Hope that helps.希望有帮助。

If you are running in the application server environment, then the maxPoolDepth property on the activationSpec will define the maximum ServerSessionPool size for the MDB - decreasing this will throttle the number messages being delivered concurrently.如果您在应用程序服务器环境中运行,则 activationSpec 上的 maxPoolDepth 属性将定义 MDB 的最大 ServerSessionPool 大小 - 减小这将限制同时传递的消息数量。

Of course, if your MDB (or javax.jms.MessageListener in the JSE environment) does nothing but hand the message to something else (or, worse, just spawn an unmanaged Thread and start it) onMessage will spin rapidly and you can still encounter problems.当然,如果您的 MDB(或 JSE 环境中的 javax.jms.MessageListener)什么都不做,只是将消息交给其他东西(或者,更糟糕的是,只是生成一个非托管线程并启动它),onMessage 将快速旋转,您仍然会遇到问题。 So in that case you need to limit other resources too, eg via threadpool configuration.因此,在这种情况下,您还需要限制其他资源,例如通过线程池配置。

Closing the connection to the QM is never an efficient way, as the MQCONN/MQDISC cycle is expensive.关闭与 QM 的连接从来都不是一种有效的方法,因为 MQCONN/MQDISC 周期很昂贵。

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

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