demo/amqp_consumer_signals.php
public function start()
    {
        if ($this->restart) {
            echo 'Restarting consumer.' . PHP_EOL;
            $this->restart = false;
        } else {
            echo 'Starting consumer.' . PHP_EOL;
        }

        $exchange = 'router';
        $queue    = 'msgs';

        $this->channel = $this->connection->channel();
        $this->channel->queue_declare($queue, false, true, false, false);
        $this->channel->exchange_declare($exchange, AMQPExchangeType::DIRECT, false, true, false);
        $this->channel->queue_bind($queue, $exchange);
        $this->channel->basic_consume(
            $queue,
            $this->consumerTag,
            false,
            false,
            false,
            false,
            [$this,'messageHandler'],
            null,
            ['x-cancel-on-ha-failover' => ['t', true]] // fail over to another node
        );

        echo 'Enter wait.' . PHP_EOL;
        while ($this->channel->is_consuming()) {
            $this->channel->wait();
        }
        echo 'Exit wait.' . PHP_EOL;
    }
public function start()
    {
        if ($this->restart) {
            echo 'Restarting consumer.' . PHP_EOL;
            $this->restart = false;
        } else {
            echo 'Starting consumer.' . PHP_EOL;
        }

        $exchange = 'router';
        $queue    = 'msgs';

        $this->channel = $this->connection->channel();
        $this->channel->queue_declare($queue, false, true, false, false);
        $this->channel->exchange_declare($exchange, AMQPExchangeType::DIRECT, false, true, false);
        $this->channel->queue_bind($queue, $exchange);
        $this->channel->basic_consume(
            $queue,
            $this->consumerTag,
            false,
            false,
            false,
            false,
            [$this,'messageHandler'],
            null,
            ['x-cancel-on-ha-failover' => ['t', true]] // fail over to another node
        );

        echo 'Enter wait.' . PHP_EOL;
        while ($this->channel->is_consuming()) {
            $this->channel->wait();
        }
        echo 'Exit wait.' . PHP_EOL;
    }
public function start ( ) { if ( $ this -> restart ) { echo 'Restarting consumer.' . PHP_EOL ; $ this -> restart = false ; } else { echo 'Starting consumer.' . PHP_EOL ; } $ exchange = 'router' ; $ queue = 'msgs' ; $ this -> channel = $ this -> connection -> channel ( ) ; $ this -> channel -> queue_declare ( $ queue , false , true , false , false ) ; $ this -> channel -> exchange_declare ( $ exchange , AMQPExchangeType :: DIRECT , false , true , false ) ; $ this -> channel -> queue_bind ( $ queue , $ exchange ) ; $ this -> channel -> basic_consume ( $ queue , $ this -> consumerTag , false , false , false , false , [ $ this , 'messageHandler' ] , null , [ 'x-cancel-on-ha-failover' => [ 't' , true ] ] // fail over to another node ) ; echo 'Enter wait.' . PHP_EOL ; while ( $ this -> channel -> is_consuming ( ) ) { $ this -> channel -> wait ( ) ; } echo 'Exit wait.' . PHP_EOL ; }
Start a consumer on an existing connection

@return void
Start a consumer on an existing connection