AMQPQueue::get

(PECL amqp >= Unknown)

AMQPQueue::getRetrieve the next message from the queue.

Descrição

public mixed AMQPQueue::get ([ int $flags = ini_get("amqp.auto_ack") ] )

Retrieve the next available message from the queue. If no messages are present in the queue, this function will return FALSE immediately. This is a non blocking alternative to the AMQPQueue::consume() method.

Currently, the only supported flag for the flags parameter is AMQP_AUTOACK. If this flag is passed in, then the message returned will automatically be marked as acknowledged by the broker as soon as the frames are sent to the client.

Parâmetros

flags

A bitmask of supported flags for the method call. Currently, the only the supported flag is AMQP_AUTOACK. If this value is not provided, it will use the value of amqp.auto_ack.

Valor Retornado

An instance of AMQPEnvelope representing the message pulled from the queue, or FALSE.

Exemplos

Exemplo #1 AMQPQueue::get() example

<?php

   
/* Create a connection using all default credentials: */
   
$connection = new AMQPConnection();
   
$connection->connect();

   
$channel = new AMQPChannel($connection);

   
/* create a queue object */
   
$queue = new AMQPQueue($channel);

   
//declare the queue
   
$queue->declare('myqueue');

   
//get the message
   
$message $queue->get(AMQP_AUTOACK);

   echo 
$message->getBody();

   
?>

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top