public function consume(callable $callback = null, $flags = AMQP_NOPARAM, $consumer_tag = null) {

        $this->last_envelope = null;

        $this->setupConsume($flags, $consumer_tag);

        while(count($this->channel->_getChannel()->callbacks) > 0){
            $this->channel->_getChannel()->wait();
            //Will unblock when there's a message
            //This handling might need to be extended to receive a batch.
            //Need to MITM the callback for the message.
            call_user_func($callback, $this->last_envelope);
        }

    }
public function consume(callable $callback = null, $flags = AMQP_NOPARAM, $consumer_tag = null) {

        $this->last_envelope = null;

        $this->setupConsume($flags, $consumer_tag);

        while(count($this->channel->_getChannel()->callbacks) > 0){
            $this->channel->_getChannel()->wait();
            //Will unblock when there's a message
            //This handling might need to be extended to receive a batch.
            //Need to MITM the callback for the message.
            call_user_func($callback, $this->last_envelope);
        }

    }
public function consume ( callable $ callback = null , $ flags = AMQP_NOPARAM , $ consumer_tag = null ) { $ this -> last_envelope = null ; $ this -> setupConsume ( $ flags , $ consumer_tag ) ; while ( count ( $ this -> channel -> _getChannel ( ) -> callbacks ) > 0 ) { $ this -> channel -> _getChannel ( ) -> wait ( ) ; //Will unblock when there's a message //This handling might need to be extended to receive a batch. //Need to MITM the callback for the message. call_user_func ( $ callback , $ this -> last_envelope ) ; } }
Consume messages from a queue.

Blocking function that will retrieve the next message from the queue as
it becomes available and will pass it off to the callback.

@param callable | null $callback A callback function to which the
consumed message will be passed. The
function must accept at a minimum
one parameter, an AMQPEnvelope object,
and an optional second parameter
the AMQPQueue object from which callback
was invoked. The AMQPQueue::consume() will
not return the processing thread back to
the PHP script until the callback
function returns FALSE.
If the callback is omitted or null is passed,
then the messages delivered to this client will
be made available to the first real callback
registered. That allows one to have a single
callback consuming from multiple queues.
@param integer $flags A bitmask of any of the flags: AMQP_AUTOACK.
@param string $consumer_tag A string describing this consumer. Used
for canceling subscriptions with cancel().

@throws AMQPChannelException    If the channel is not open.
@throws AMQPConnectionException If the connection to the broker was lost.

@return void
Consume messages from a queue .