本文整理汇总了PHP中msg_stat_queue函数的典型用法代码示例。如果您正苦于以下问题:PHP msg_stat_queue函数的具体用法?PHP msg_stat_queue怎么用?PHP msg_stat_queue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了msg_stat_queue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(Config $config)
{
$this->ownerPid = $config->get('ownerPid');
$this->ipcKey = new IpcKey($this->ownerPid, str_replace('\\', '_', get_class($this)));
$this->id = msg_get_queue($this->ipcKey->generate());
$this->stat = msg_stat_queue($this->id);
}
示例2: mqPeek
/**
Peek at a Message Queue Return the Number of Messages
*/
static function mqPeek($name)
{
$mq = msg_get_queue(self::_ftok($name));
$stat = msg_stat_queue($mq);
return $stat['msg_qnum'];
// Items in the Queue
}
示例3: fillQueueGeneralInformation
private function fillQueueGeneralInformation()
{
$status = msg_stat_queue($this->resource);
$this->ownerId = $status['msg_perm.uid'];
$this->ownerGroupId = $status['msg_perm.gid'];
$this->messageAllowedSize = $status['msg_qbytes'];
}
示例4: count
/**
* {@inheritdoc}
*/
public function count()
{
$data = msg_stat_queue($this->getQueue());
if (!is_array($data)) {
throw new QueueException($this, 'Failed to get the meta data for the queue.');
}
return $data['msg_qnum'];
}
示例5: putMessage
public function putMessage(&$message)
{
$messageId = $this->storage->saveMessage($message);
// notify queue via ipc
$ipcStat = msg_stat_queue($this->ipcChannel);
if (is_array($ipcStat) && $ipcStat['msg_qnum'] < 5) {
msg_send($this->ipcChannel, 1, '*', false, false, $ipcError);
}
return $messageId;
}
示例6: addMessage
/**
* addMessage: Given a key, store a new message into our queue.
*
* @param $key string - Reference to the message (PK)
* @param $data array - Some data to pass into the message
*/
public static function addMessage($key, $data = array())
{
# What to send
$message = new Message($key, $data);
# Try to send the message
if (msg_send(self::$queue, QUEUE_TYPE_START, $message)) {
print_r(msg_stat_queue(self::$queue));
} else {
echo "Error adding to the queue";
}
}
示例7: initQueue
public static function initQueue($queue_file)
{
if (!file_exists($queue_file)) {
touch($queue_file);
}
$msg_id = msg_get_queue(ftok($queue_file, 'r'), 0666);
// Remove any messages in queue
$queue = msg_stat_queue($msg_id);
if ($queue['msg_qnum'] > 0) {
msg_remove_queue($msg_id);
$msg_id = msg_get_queue(ftok($queue_file, 'r'), 0666);
}
return $msg_id;
}
示例8: showAllDaemon
private function showAllDaemon()
{
$messageQueueKey = ftok(App::path('cache') . "/queue/daemon.queue", "a");
$messageQueue = msg_get_queue($messageQueueKey, 0666);
$messageQueueState = msg_stat_queue($messageQueue);
$msgCount = $messageQueueState['msg_qnum'];
if (0 === $msgCount) {
Console::line("None service is running.");
}
while ($msgCount > 0) {
/** @var MessageQueue $message */
msg_receive($messageQueue, 0, $messageType, 1024, $message, true, MSG_IPC_NOWAIT);
Console::line("PID:{$message->pid},NAME:{$message->name},TIME:" . date("Y-m-d H:i:s", $message->timestamp) . "Alive.");
$messageQueueState = msg_stat_queue($messageQueue);
$msgCount = $messageQueueState['msg_qnum'];
}
}
示例9: __destruct
/**
* The class destructor.
*/
public function __destruct()
{
parent::__destruct();
if ($this->iAmParent()) {
$desiredType = 1;
$option_receive = MSG_IPC_NOWAIT;
$stats = msg_stat_queue($this->queueResourceResponse);
$queueMessageSize = $stats['msg_qbytes'];
// the Report
$messageReport = '';
// receive the report
$stats = msg_stat_queue($this->queueResourceResponse);
while ($stats['msg_qnum']) {
//for($i=0;count($all_servers);$i++){
$status = msg_receive($this->queueResourceResponse, $desiredType, $type, $queueMessageSize, $mixed, true, $option_receive);
if ($status == true) {
$messageReport .= $mixed['message'];
if ($mixed['return'] < 0) {
// check if server counldn't do the backups because shutdown doesn't work
if ($mixed['error'] && $mixed['error']['error']['error'] == '_ERR_VM_BACKUP_STILL_RUNNING_') {
$etva_server = $mixed['server'];
$this->log("[WARN] Receive error that VM '" . $etva_server->getName() . "' couldn't make backup beacuse is still running, so i will try start again...");
$etva_node = $etva_server->getEtvaNode();
if ($etva_node) {
$res_start = $etva_node->soapSend(EtvaServer_VA::SERVER_START, array('uuid' => $etva_server->getUuid(), 'name' => $etva_server->getName()));
$this->log("[WARN] Start '" . $etva_server->getName() . "' VM and receive the following message: " . print_r($res_start, true));
}
}
}
} else {
$err_m = "[ERROR] Receive error when wait for response... " . print_r($err, true);
$messageReport .= $err_m . "\r\n";
$this->log($err_m);
}
$stats = msg_stat_queue($this->queueResourceResponse);
}
msg_remove_queue($this->queueResourceResponse);
//$this->log($messageReport);
$this->sendReport($messageReport);
}
}
示例10: count
/**
* {@inheritdoc}
*/
public function count()
{
$stat = msg_stat_queue($this->queue);
return $stat['msg_qnum'];
}
示例11: define
<?php
// link: http://www.ebrueggeman.com/blog/creating-a-message-queue-in-php
// filename: add_to_queue.php
//creating a queue requires we come up with an arbitrary number
define('QUEUE', 21671);
//add message to queue
$queue = msg_get_queue(QUEUE);
// Create dummy message object
$object = new stdclass();
$object->name = 'foo';
$object->id = uniqid();
$object->data = array('name' => 'Ligia');
//try to add message to queue
if (msg_send($queue, 1, $object)) {
echo "added to queue \n";
// you can use the msg_stat_queue() function to see queue status
print_r(msg_stat_queue($queue));
} else {
echo "could not add message to queue \n";
}
示例12: stats
public function stats()
{
return msg_stat_queue($this->queue);
}
示例13: json_decode
$json = json_decode(file_get_contents($file));
foreach ($json->queue as $queue) {
?>
<tr>
<td><?php
echo $queue;
?>
</td>
<td>
<?php
if (msg_queue_exists($queue)) {
echo "ON";
} else {
echo "OFF";
}
?>
</td>
<td>
<?php
if (msg_queue_exists($queue)) {
$openqueue = msg_get_queue($queue);
echo msg_stat_queue($openqueue)['msg_qnum'];
} else {
echo "---";
}
?>
</td>
</tr>
<?php
}
示例14: count
public function count($queueName)
{
$stats = msg_stat_queue($this->getQueue($queueName));
return $stats['msg_qnum'];
}
示例15: non_blocking_in
public function non_blocking_in($msg)
{
if ($this->closed || !msg_queue_exists($this->key)) {
return self::CLOSED;
}
$shm = new Message();
$shm->store($msg);
$error = 0;
@msg_send($this->ipc, 1, $shm->key(), false, false, $error);
if (MSG_EAGAIN === $error) {
$shmAbortedMessage = new Message($shm->key());
$shmAbortedMessage->destroy();
return false;
}
++$this->msg_count;
$first_loop = true;
do {
$data = msg_stat_queue($this->ipc);
if (!$first_loop && 0 == $data['msg_qnum']) {
break;
}
$first_loop = false;
} while (true);
return true;
}