[英]ActiveMQ not returning message when queue has n number of pending messages
Environment/Background: 环境/背景:
Using PHP Stomp library to send and receive message from ActiveMQ (v5.4.3). 使用PHP Stomp库从ActiveMQ(v5.4.3)发送和接收消息。
Steps: 脚步:
The above steps works fine when there is no pending message or pending message < n. 当没有未决消息或未决消息<n时,上述步骤可以正常工作。 In my case, n =200.
在我的情况下,n = 200。 When the number of pending message is > 200, the message is not delivered.
当待处理消息的数量> 200时,该消息将不发送。 The process waits till timeout and finally timeout without response.
该过程一直等到超时,最后超时而没有响应。 I can see the message (using admin UI) after timeout.
超时后,我可以看到该消息(使用管理界面)。 Here is the code that I'm using for this case:
这是我在这种情况下使用的代码:
<?php
// make a connection
$con = new Stomp("tcp://localhost:61616");
// Set read timeout.
$con->setReadTimeout(10);
// Prepare request variables.
$correlation_id = rand();
$request_queue = '/queue/com.domain.service.request';
$response_queue = '/queue/com.domain.service.response';
$selector = "JMSCorrelationID='$correlation_id'";
$headers = array('correlation-id' => $correlation_id, 'reply-to' => $response_queue);
$message = '<RequestBody></RequestBody>';
// send a message to the queue.
$con->send($request_queue, $message, $headers);
// subscribe to the queue
$con->subscribe($response_queue, array('selector' => $selector, 'ack' => 'auto'));
// receive a message from the queue
$msg = $con->readFrame();
// do what you want with the message
if ( $msg != null) {
echo "Received message with body\n";
var_dump($msg);
// mark the message as received in the queue
$con->ack($msg);
} else {
echo "Failed to receive a message\n";
}
unset($con);
Other findings: 其他发现:
Sending messages from one file (say from sender.php) and receive using another script (say receiver.php) working fine. 从一个文件发送消息(例如,从sender.php发送消息),并使用另一个脚本(例如,receiver.php)接收消息,可以正常工作。
Allows to send more than 1000 message in the same request queue(and eventually processed and placed in response queue). 允许在同一请求队列中发送1000条以上的消息(并最终进行处理并放入响应队列中)。 So it doesn't look like memory issue.
因此,它看起来不像是内存问题。
Funny enough, while waiting for timeout, if I browse the queue on admin UI, I get the response. 有趣的是,在等待超时的同时,如果我在管理UI上浏览队列,则会收到响应。
By default, the stomp broker that I use set the prefetch size to 1. 默认情况下,我使用的脚踏代理将预取大小设置为1。
Without knowing more my guess is that you have multiple consumers and one is hogging the messages in it's prefetch buffer, the default size is 1000 I think. 在不知道更多信息的情况下,您有多个使用者,并且正在将消息存储在预取缓冲区中,我认为默认大小为1000。 To debug situations like this it's usually a good idea to look at the web console or connect with jconsole and inspect the Queue MBean to see the stats for in-flight messages, number of consumers etc.
要调试这种情况,通常最好查看Web控制台或与jconsole连接并检查Queue MBean,以查看运行中消息的统计信息,使用方数量等。
Answering my own question. 回答我自己的问题。
The problem I'm facing is exactly what is described in http://trenaman.blogspot.co.uk/2009/01/message-selectors-and-activemq.html and the solution is to increase the maxPageSize as specified in ActiveMQ and maxPageSize 我面临的问题正是http://trenaman.blogspot.co.uk/2009/01/message-selectors-and-activemq.html中描述的问题,解决方案是按照ActiveMQ和maxpagesize可
As you can match that the 200 is not a varying number, but the default value of maxPageSize. 您可以匹配到200不是可变数字,而是maxPageSize的默认值。
More references: 更多参考:
http://activemq.2283324.n4.nabble.com/Consumer-is-not-able-to-pick-messages-from-queue-td2531722.html http://activemq.2283324.n4.nabble.com/Consumer-is-not-able-to-pick-messages-from-queue-td2531722.html
https://issues.apache.org/jira/browse/AMQ-2217 https://issues.apache.org/jira/browse/AMQ-2217
https://issues.apache.org/jira/browse/AMQ-2745 https://issues.apache.org/jira/browse/AMQ-2745
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.