当前位置: 首页>>代码示例>>PHP>>正文


PHP AMQPChannel::exchange_declare方法代码示例

本文整理汇总了PHP中PhpAmqpLib\Channel\AMQPChannel::exchange_declare方法的典型用法代码示例。如果您正苦于以下问题:PHP AMQPChannel::exchange_declare方法的具体用法?PHP AMQPChannel::exchange_declare怎么用?PHP AMQPChannel::exchange_declare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhpAmqpLib\Channel\AMQPChannel的用法示例。


在下文中一共展示了AMQPChannel::exchange_declare方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setup

 /**
  * @throws Exception\Configuration
  */
 public function setup()
 {
     $this->connect();
     $exchange = $this->getProperty('exchange');
     if (empty($exchange)) {
         throw new Exception\Configuration('Please check your settings, exchange is not defined.');
     }
     /*
         name: $exchange
         type: topic
         passive: false
         durable: true // the exchange will survive server restarts
         auto_delete: false //the exchange won't be deleted once the channel is closed.
     */
     $this->channel->exchange_declare($exchange, $this->getProperty('exchange_type'), $this->getProperty('exchange_passive'), $this->getProperty('exchange_durable'), $this->getProperty('exchange_auto_delete'), $this->getProperty('exchange_internal'), $this->getProperty('exchange_nowait'), $this->getProperty('exchange_properties'));
     $queue = $this->getProperty('queue');
     if (!empty($queue) || $this->getProperty('queue_force_declare')) {
         /*
             name: $queue
             passive: false
             durable: true // the queue will survive server restarts
             exclusive: false // queue is deleted when connection closes
             auto_delete: false //the queue won't be deleted once the channel is closed.
             nowait: false // Doesn't wait on replies for certain things.
             parameters: array // Extra data, like high availability params
         */
         /** @var ['queue name', 'message count',] queueInfo */
         $this->queueInfo = $this->channel->queue_declare($queue, $this->getProperty('queue_passive'), $this->getProperty('queue_durable'), $this->getProperty('queue_exclusive'), $this->getProperty('queue_auto_delete'), $this->getProperty('queue_nowait'), $this->getProperty('queue_properties'));
         $this->channel->queue_bind($queue ?: $this->queueInfo[0], $exchange, $this->getProperty('routing'));
     }
     // clear at shutdown
     register_shutdown_function([get_class(), 'shutdown'], $this->channel, $this->connection);
 }
开发者ID:bschmitt,项目名称:laravel-amqp,代码行数:36,代码来源:Request.php

示例2: __construct

 /**
  * @param AMQPStreamConnection $conn
  */
 public function __construct(AMQPStreamConnection $conn)
 {
     $this->conn = $conn;
     $this->channel = $conn->channel();
     list($this->queueName) = $this->channel->queue_declare('', false, true, true, false);
     $this->channel->exchange_declare(self::TOPIC_NAME, self::MESSAGE_TYPE, false, true, true, false);
 }
开发者ID:evertharmeling,项目名称:brouwkuyp-control,代码行数:10,代码来源:Manager.php

示例3: runAndWait

 /**
  * {@inheritdoc}
  */
 public function runAndWait(Task $task, $wait = 0, callable $completed = null, callable $timedout = null, callable $errored = null)
 {
     $waitForResult = $wait > 0;
     // Event: before dispatching the task
     $this->triggerEvent(self::EVENT_BEFORE_TASK_DISPATCHED, [$task]);
     // Event: before serialization
     $this->triggerEvent(self::EVENT_BEFORE_TASK_SERIALIZATION, [$task]);
     $messageOptions = ['delivery_mode' => 2];
     $replyExchange = null;
     $replyQueue = null;
     if ($waitForResult) {
         // Create a temporary exchange (durable, autodelete) for communicating with the worker
         $replyExchange = uniqid('tmp');
         $this->channel->exchange_declare($replyExchange, 'fanout', false, true, true);
         // Create and bind a queue for the dispatcher (our queue) (exclusive queue)
         list($replyQueue, , ) = $this->channel->queue_declare('', false, false, true);
         $this->channel->queue_bind($replyQueue, $replyExchange);
         // Create and bind a queue for the worker (durable non-exclusive queue)
         list($workerReplyQueue, , ) = $this->channel->queue_declare('', false, true, false);
         $this->channel->queue_bind($workerReplyQueue, $replyExchange);
         $messageOptions['reply_to'] = $replyExchange . ';' . $workerReplyQueue;
     }
     $message = new AMQPMessage(serialize($task), $messageOptions);
     $this->channel->basic_publish($message, '', $this->queue);
     if ($waitForResult) {
         $this->waitForTask($wait, $replyExchange, $replyQueue, $completed, $timedout, $errored);
     }
 }
开发者ID:basuritas-php,项目名称:php-Work,代码行数:31,代码来源:RabbitMQWorkDispatcher.php

示例4: setUp

 public function setUp()
 {
     $this->conn = $this->createConnection();
     $this->ch = $this->conn->channel();
     $this->ch->exchange_declare($this->exchange_name, 'direct', false, false, false);
     list($this->queue_name, , ) = $this->ch->queue_declare();
     $this->ch->queue_bind($this->queue_name, $this->exchange_name, $this->queue_name);
 }
开发者ID:vongrad,项目名称:loanbroker,代码行数:8,代码来源:AbstractPublishConsumeTest.php

示例5: setUpAmqp

 protected function setUpAmqp()
 {
     $this->conn = new AMQPSocketConnection($_SERVER['AMQP_HOST'], $_SERVER['AMQP_PORT'], $_SERVER['AMQP_USER'], $_SERVER['AMQP_PASS'], $_SERVER['AMQP_VHOST']);
     $this->channel = $this->conn->channel();
     $this->channel->exchange_declare('event_band.test.exchange', 'topic');
     $this->channel->queue_declare('event_band.test.event');
     $this->channel->queue_bind('event_band.test.event', 'event_band.test.exchange', 'event.#');
 }
开发者ID:Gangstel,项目名称:EventBandAmqpLibTransport,代码行数:8,代码来源:AmqpLibDriverTest.php

示例6: getChannel

 /**
  * Gets publisher AMQ channel
  *
  * @return AMQPChannel
  */
 protected function getChannel()
 {
     if (null === $this->channel) {
         $this->channel = $this->amq->channel();
         $this->channel->exchange_declare($this->exchange, 'topic', false, true, false);
     }
     return $this->channel;
 }
开发者ID:legolaiko,项目名称:amqp-smart-message,代码行数:13,代码来源:MessagePublisher.php

示例7: setUp

 public function setUp()
 {
     $this->conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
     $this->ch = $this->conn->channel();
     $this->ch->exchange_declare($this->exchange_name, 'direct', false, false, false);
     list($this->queue_name, , ) = $this->ch->queue_declare();
     $this->ch->queue_bind($this->queue_name, $this->exchange_name, $this->queue_name);
 }
开发者ID:vongrad,项目名称:loanbroker,代码行数:8,代码来源:FileTransferTest.php

示例8: declareExchange

 /**
  * Declare a exchange in the message broker.
  *
  * If the exchange is already declared, the configuration MUST match. If the exchange has not been
  * defined before, it'll be created.
  *
  * @param AbstractExchange $exchange
  *
  * @return $this
  *
  * @throws BrokerException
  */
 public function declareExchange($exchange)
 {
     if (!$exchange instanceof AbstractExchange) {
         throw new BrokerException("The exchange hasn't been defined");
     }
     $this->channel->exchange_declare($exchange->getName(), $exchange->getExchangeType(), $exchange->isPassive(), $exchange->isDurable(), $exchange->isDeclaredAutoDelete(), $exchange->isInternal(), $exchange->isDeclaredAsNoWait(), $exchange->getArguments());
     return $this;
 }
开发者ID:znk3r,项目名称:mqlib,代码行数:20,代码来源:Channel.php

示例9: connect

 /**
  *
  */
 private function connect()
 {
     if (!$this->connection) {
         $this->connection = new AMQPStreamConnection($this->host, $this->port, 'guest', 'guest');
         $this->channel = $this->connection->channel();
         $this->channel->exchange_declare($this->channel_name, 'fanout', false, false, false);
     }
 }
开发者ID:RepoMon,项目名称:scheduler,代码行数:11,代码来源:QueueClient.php

示例10: connect

 /**
  * @param $exchange_name
  */
 private function connect($exchange_name)
 {
     if (null !== $this->channel) {
         return;
     }
     $this->channel = $this->connection->channel();
     $this->channel->exchange_declare($exchange_name, 'fanout', false, true, false);
     $this->channel->queue_declare($exchange_name, false, true, false, false);
     $this->channel->queue_bind($exchange_name, $exchange_name);
 }
开发者ID:loobee,项目名称:ddd,代码行数:13,代码来源:RabbitMqMessageProducer.php

示例11: initialize

 /**
  * @return string
  */
 public function initialize()
 {
     $inbox = 'inbox.' . $this->handler->name();
     $queue = $this->handler->name();
     $this->channel->exchange_declare($inbox, 'topic', false, true, false);
     $this->channel->exchange_bind($inbox, 'inbox', '', false, new AMQPTable(['to' => '*']));
     $this->channel->exchange_bind($inbox, 'inbox', '', false, new AMQPTable(['to' => $this->handler->name()]));
     $this->channel->queue_declare($queue, false, true, false, false, false);
     $this->channel->queue_bind($queue, $inbox, '#');
     return $queue;
 }
开发者ID:skolodyazhnyy,项目名称:message-bus-client,代码行数:14,代码来源:Consumer.php

示例12: initialize

 /**
  * @return void
  */
 public function initialize()
 {
     if ($this->initialized) {
         return;
     }
     $this->initialized = true;
     $this->channel->exchange_declare($this->name, $this->type, $this->passive, $this->durable, $this->autoDelete);
     foreach ($this->bindings as $binding) {
         $binding->initialize();
     }
 }
开发者ID:bcncommerce,项目名称:rabbitmq-extension,代码行数:14,代码来源:Exchange.php

示例13: declareComponents

 private function declareComponents($routingKey, $exchange, $queue = null)
 {
     $this->channel->exchange_declare('dead_letters', 'topic', false, true, false);
     if ($queue !== null) {
         $this->channel->queue_declare('dead_letter:' . $queue, false, true, false, false);
         $this->channel->queue_bind('dead_letter:' . $queue, 'dead_letters', $routingKey . '.dead_letter');
     }
     $this->channel->exchange_declare($exchange, 'topic', false, true, false);
     if ($queue !== null) {
         $this->channel->queue_declare($queue, false, true, false, false, false, new AMQPTable(['x-dead-letter-exchange' => 'dead_letters', 'x-dead-letter-routing-key' => $routingKey . '.dead_letter']));
         $this->channel->queue_bind($queue, $exchange, $routingKey);
     }
 }
开发者ID:ajouve,项目名称:rabbit-mq-wrapper,代码行数:13,代码来源:Client.php

示例14: getExchange

 /**
  * @param $queue
  *
  * @return string
  */
 protected function getExchange($queue)
 {
     if (!array_key_exists($queue, $this->exchangeList)) {
         /**
          * queue and exchange the same
          */
         $exchange = $queue;
         $this->ch->queue_declare($queue, false, true, false, false);
         $this->ch->exchange_declare($exchange, 'direct', false, true, false);
         $this->ch->queue_bind($queue, $exchange);
         $this->exchangeList[$exchange] = $exchange;
     }
     return $queue;
 }
开发者ID:miracle84,项目名称:johnny5,代码行数:19,代码来源:RabbitMQService.php

示例15: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     if (!isset($_SERVER['AMQP_HOST'])) {
         $this->markTestSkipped('This test require AMQP Server, use AMQP_HOST, AMQP_PORT, AMQP_USER, AMQP_PASSWORD, AMQP_VHOST environment variables to set connection details');
     }
     $this->exchange = uniqid('phpunit.');
     $env = function ($key, $default = null) {
         return isset($_SERVER[$key]) ? $_SERVER[$key] : $default;
     };
     $this->connection = new AMQPStreamConnection($env('AMQP_HOST', 'localhost'), $env('AMQP_PORT', 5672), $env('AMQP_USER', 'guest'), $env('AMQP_PASSWORD', 'guest'), $env('AMQP_VHOST', '/'));
     $this->channel = $this->connection->channel();
     $this->channel->exchange_declare($this->exchange, 'fanout');
     $this->client = new ServiceBus(new Driver($this->channel, $this->exchange, new JsonEncoder()));
     $this->initialize();
 }
开发者ID:skolodyazhnyy,项目名称:message-bus-client,代码行数:18,代码来源:AMQPClientTest.php


注:本文中的PhpAmqpLib\Channel\AMQPChannel::exchange_declare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。