在php中,我可以像这样用Stomp从activeMQ读取消息:
$consumer = new Stomp("tcp://localhost:61613");
$consumer->clientId = "test";
$consumer->connect();
$consumer->subscribe("/topic/test");
$msg = $consumer->readFrame();
if ( $msg != null) {
echo "Message '$msg->body' received from topic\n";
$consumer->ack($msg);
} else {
echo "Failed to receive a message\n";
}
但是在读取一条消息后php脚本结束(似乎是逻辑上的),我们如何才能像JAVA中那样拥有一个始终处于活动状态的消耗者,当生产者将其发送到队列时,该消耗者就可以读取消息了?