@@ 555-580 (lines=26) @@ | ||
552 | * @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException |
|
553 | * @throws \PHPDaemon\Clients\AMQP\Driver\Exception\AMQPChannelException |
|
554 | */ |
|
555 | public function bindExchange($name, $exchangeName, $routingKey, array $options = [], callable $callback = null) |
|
556 | { |
|
557 | if (!$this->connection->getFeatures()->exchangeToExchangeBindings) { |
|
558 | throw new AMQPChannelException('Broker does not support exchange to exchange bindings'); |
|
559 | } |
|
560 | ||
561 | if ($exchangeName === $name) { |
|
562 | throw new AMQPChannelException('Exchange cannot bind to itself'); |
|
563 | } |
|
564 | ||
565 | $noWait = array_key_exists('noWait', $options) ? $options['noWait'] : false; |
|
566 | ||
567 | $outputFrame = Exchange\ExchangeBindFrame::create( |
|
568 | $name, |
|
569 | $exchangeName, |
|
570 | $routingKey, |
|
571 | $noWait, |
|
572 | $options |
|
573 | ); |
|
574 | $outputFrame->frameChannelId = $this->id; |
|
575 | $this->connection->command($outputFrame); |
|
576 | ||
577 | if (is_callable($callback)) { |
|
578 | $this->on(self::EVENT_ON_CHANNEL_BIND_EXCHANGE_CALLBACK, $callback); |
|
579 | } |
|
580 | } |
|
581 | ||
582 | /** |
|
583 | * Unbind exchange |
|
@@ 594-619 (lines=26) @@ | ||
591 | * @throws \PHPDaemon\Clients\AMQP\Driver\Exception\AMQPChannelException |
|
592 | * @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException |
|
593 | */ |
|
594 | public function unbindExchange($name, $exchangeName, $routingKey, array $options = [], callable $callback = null) |
|
595 | { |
|
596 | if (!$this->connection->getFeatures()->exchangeToExchangeBindings) { |
|
597 | throw new AMQPChannelException('Broker does not support exchange to exchange bindings'); |
|
598 | } |
|
599 | ||
600 | if ($exchangeName === $name) { |
|
601 | throw new AMQPChannelException('Exchange cannot unbind itself'); |
|
602 | } |
|
603 | ||
604 | $noWait = array_key_exists('noWait', $options) ? $options['noWait'] : false; |
|
605 | ||
606 | $outputFrame = Exchange\ExchangeUnbindFrame::create( |
|
607 | $name, |
|
608 | $exchangeName, |
|
609 | $routingKey, |
|
610 | $noWait, |
|
611 | $options |
|
612 | ); |
|
613 | $outputFrame->frameChannelId = $this->id; |
|
614 | $this->connection->command($outputFrame); |
|
615 | ||
616 | if (is_callable($callback)) { |
|
617 | $this->on(self::EVENT_ON_CHANNEL_UNBIND_EXCHANGE_CALLBACK, $callback); |
|
618 | } |
|
619 | } |
|
620 | ||
621 | /** |
|
622 | * Publish message to exchange |