[英]ActiveMQ not returning message when queue has n number of pending messages
环境/背景:
使用PHP Stomp库从ActiveMQ(v5.4.3)发送和接收消息。
脚步:
当没有未决消息或未决消息<n时,上述步骤可以正常工作。 在我的情况下,n = 200。 当待处理消息的数量> 200时,该消息将不发送。 该过程一直等到超时,最后超时而没有响应。 超时后,我可以看到该消息(使用管理界面)。 这是我在这种情况下使用的代码:
<?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);
其他发现:
从一个文件发送消息(例如,从sender.php发送消息),并使用另一个脚本(例如,receiver.php)接收消息,可以正常工作。
允许在同一请求队列中发送1000条以上的消息(并最终进行处理并放入响应队列中)。 因此,它看起来不像是内存问题。
有趣的是,在等待超时的同时,如果我在管理UI上浏览队列,则会收到响应。
默认情况下,我使用的脚踏代理将预取大小设置为1。
在不知道更多信息的情况下,您有多个使用者,并且正在将消息存储在预取缓冲区中,我认为默认大小为1000。 要调试这种情况,通常最好查看Web控制台或与jconsole连接并检查Queue MBean,以查看运行中消息的统计信息,使用方数量等。
回答我自己的问题。
我面临的问题正是http://trenaman.blogspot.co.uk/2009/01/message-selectors-and-activemq.html中描述的问题,解决方案是按照ActiveMQ和maxpagesize可
您可以匹配到200不是可变数字,而是maxPageSize的默认值。
更多参考:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.