/* php.ini
[stomp]
stomp.default_connection_timeout_sec = 10
stomp.default_read_timeout_sec = 15
這些值不應保留為預設值。
如果佇列伺服器非常忙碌,且佇列中有很多訊息時,
兩秒內沒有回應訊框。
*/
try {
$stomp = new Stomp(self::geturl, self::username, self::password, array('client-id' => gethostname()."-".uniqid(mt_rand(), true)));
$stomp->subscribe(self::getqueue, array('selector' => sprintf(self::selector, $queue_id)));
/* 讀取一個訊框 */
$frame = $stomp->readFrame();
if ($frame) {
$stomp->ack($frame);
unset($stomp);
return $frame;
}
unset($stomp);
} // 沒有 frame 則回傳 false
} catch (StompException $e) {
print ('連線失敗:' . $e->getMessage());
unset($stomp);
} // 沒有 frame 則回傳 false
}
/* 關閉連線 */
unset($stomp);