AMQPExchange::bind PHP Метод

bind() публичный Метод

Bind an exchange to another exchange using the specified routing key.
public bind ( string $exchange_name, string $routing_key = '', array $arguments = [] ) : boolean
$exchange_name string Name of the exchange to bind.
$routing_key string The routing key to use for binding.
$arguments array Additional binding arguments.
Результат boolean true on success or false on failure.
    public function bind($exchange_name, $routing_key = '', array $arguments = array())
    {
    }

Usage Example

Пример #1
0
 public function Run()
 {
     // Declare a new exchange
     $ex = new AMQPExchange($this->cnn);
     $ex->declare('game', AMQP_EX_TYPE_FANOUT);
     // Create a new queue
     $q1 = new AMQPQueue($this->cnn);
     $q1->declare('queue1');
     $q2 = new AMQPQueue($this->cnn);
     $q2->declare('queue2');
     // Bind it on the exchange to routing.key
     //$ex->bind('queue1', 'broadcast=true,target=queue1,x-match=any');
     $ex->bind('queue1', '');
     $ex->bind('queue2', '');
     $msgBody = 'hello';
     // Publish a message to the exchange with a routing key
     $ex->publish($msgBody, 'foo');
     // Read from the queue
     $msg = $q1->consume();
     $this->AssertEquals(count($msg), 1);
     $this->AssertEquals($msg[0]['message_body'], $msgBody, 'message not equal');
     // Read from the queue
     $msg = $q2->consume();
     $this->AssertEquals(count($msg), 1);
     $this->AssertEquals($msg[0]['message_body'], $msgBody, 'message not equal');
     $this->AddMessage(var_export($msg[0], true));
 }
All Usage Examples Of AMQPExchange::bind