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


PHP AMQPExchange::declareExchange方法代码示例

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


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

示例1: initialize

 /**
  * @param \AMQPExchange|null $exchange
  *
  * @throws HectorException
  */
 public function initialize(\AMQPExchange $exchange = null)
 {
     if (null == $exchange) {
         $exchange = new \AMQPExchange($this->channel->getWrappedChannel());
     }
     $this->exchange = $exchange;
     $this->exchange->setName($this->getName());
     $this->exchange->setType($this->context->getType());
     $this->exchange->setArguments($this->context->getArguments());
     $this->exchange->setFlags((int) $this->context->getFlags());
     $this->exchange->declareExchange();
     $this->initialized = true;
 }
开发者ID:Evaneos,项目名称:Hector,代码行数:18,代码来源:Exchange.php

示例2: declareExchange

 /**
  * @return bool
  */
 public function declareExchange()
 {
     try {
         return $this->rawExchange->declareExchange();
     } catch (\Exception $e) {
         ClientHelper::throwRightException($e);
     }
 }
开发者ID:csharpru,项目名称:yii2-amqp,代码行数:11,代码来源:Exchange.php

示例3: declareExchange

 public function declareExchange($name, $type = AMQP_EX_TYPE_TOPIC, $flags = AMQP_DURABLE)
 {
     $exchange = new \AMQPExchange($this->channel);
     $exchange->setName($name);
     $exchange->setType($type);
     $exchange->setFlags($flags);
     $exchange->declareExchange();
     return $exchange;
 }
开发者ID:Jmoati,项目名称:SwarrotBootstrapBundle,代码行数:9,代码来源:PeclAmqpPackageProvider.php

示例4: declareExchange

 /**
  * @inheritdoc
  */
 public function declareExchange()
 {
     try {
         return $this->delegate->declareExchange();
     } catch (\AMQPExchangeException $e) {
         throw new ExchangeException($e->getMessage(), $e->getCode(), $e);
     } catch (\AMQPChannelException $e) {
         throw new ChannelException($e->getMessage(), $e->getCode(), $e);
     } catch (\AMQPConnectionException $e) {
         throw new ConnectionException($e->getMessage(), $e->getCode(), $e);
     }
 }
开发者ID:treehouselabs,项目名称:queue,代码行数:15,代码来源:Exchange.php

示例5: getExchange

 /**
  * @return \AMQPExchange
  * @throws \Exception
  */
 protected function getExchange()
 {
     if (!$this->exchange) {
         $this->exchange = new \AMQPExchange($this->getChannel());
         $this->exchange->setName($this->exchangeConfig['name']);
         $this->exchange->setType($this->exchangeConfig['type']);
         $this->exchange->setArguments($this->exchangeConfig['arguments']);
         $this->exchange->setFlags($this->exchangeConfig['flags']);
         if (!$this->exchange->declareExchange()) {
             throw new \Exception('Can not declare exchange ' . $this->exchange->getName());
         }
     }
     return $this->exchange;
 }
开发者ID:paulchyrilov,项目名称:zf2-rabbitmq-eventbus-module,代码行数:18,代码来源:EventBusAdapter.php

示例6: createExchange

 /**
  * {@inheritDoc}
  */
 public function createExchange()
 {
     // Create AMQP connection
     $amqpConnection = new \AMQPConnection(['host' => $this->host, 'port' => $this->port, 'vhost' => $this->vhost, 'login' => $this->login, 'password' => $this->password]);
     $amqpConnection->connect();
     // Create channel
     $channel = new \AMQPChannel($amqpConnection);
     // Create exchange
     $exchange = new \AMQPExchange($channel);
     $exchange->setName($this->exchangeName);
     $exchange->setType($this->exchangeType);
     $exchange->setFlags(AMQP_DURABLE);
     $exchange->declareExchange();
     return $exchange;
 }
开发者ID:Gtvar,项目名称:FivePercent-IntegrationBundle,代码行数:18,代码来源:ConfigExchangeFactory.php

示例7: setupConnection

 public static function setupConnection(\AMQPConnection $connection, $config)
 {
     $channel = new \AMQPChannel($connection);
     $exchange = new \AMQPExchange($channel);
     $exchange->setName($config['exchange_name']);
     $exchange->setType(AMQP_EX_TYPE_DIRECT);
     $exchange->setFlags(AMQP_DURABLE);
     $exchange->declareExchange();
     $queue = new \AMQPQueue($channel);
     $queue->setName($config['queue_name']);
     $queue->setFlags(AMQP_DURABLE);
     $queue->declareQueue();
     //        $exchange->bind($config['queue_name'], 'gos.websocket.pusher');
     return [$channel, $exchange, $queue];
 }
开发者ID:rsrodrig,项目名称:MeetMeSoftware,代码行数:15,代码来源:Utils.php

示例8: exchangeDeclare

 protected function exchangeDeclare()
 {
     if ($this->exchange === null) {
         $this->exchange = new AMQPExchange($this->channel);
     }
     $this->exchange->setName($this->exchangeOptions['name']);
     $this->exchange->setType($this->exchangeOptions['type']);
     $this->exchange->setFlags($this->getFlagsFromOptions());
     $this->exchange->setArguments($this->exchangeOptions['arguments']);
     $this->exchange->declareExchange();
     foreach ($this->exchangeOptions['binding'] as $bindOpt) {
         $this->exchange->bind($bindOpt['name'], $bindOpt['routing-keys']);
     }
     $this->exchangeDeclared = true;
 }
开发者ID:umpirsky,项目名称:ko-worker,代码行数:15,代码来源:Producer.php

示例9: setUpAmqp

 /**
  * {@inheritDoc}
  */
 protected function setUpAmqp()
 {
     $this->conn = new \AMQPConnection(['host' => $_SERVER['AMQP_HOST'], 'port' => $_SERVER['AMQP_PORT'], 'login' => $_SERVER['AMQP_USER'], 'password' => $_SERVER['AMQP_PASS'], 'vhost' => $_SERVER['AMQP_VHOST']]);
     $this->conn->connect();
     $channel = new \AMQPChannel($this->conn);
     $exchange = new \AMQPExchange($channel);
     $exchange->setName('event_band.test.exchange');
     $exchange->setFlags(AMQP_AUTODELETE);
     $exchange->setType(AMQP_EX_TYPE_TOPIC);
     $exchange->declareExchange();
     $queue = new \AMQPQueue($channel);
     $queue->setName('event_band.test.event');
     $queue->declareQueue();
     $queue->bind('event_band.test.exchange', 'event.#');
 }
开发者ID:event-band,项目名称:band-transport-amqp-pecl,代码行数:18,代码来源:PeclAmqpDriverTest.php

示例10: send

 public function send($msg)
 {
     $channel = new \AMQPChannel($this->connection);
     $exchange = new \AMQPExchange($channel);
     $exchange->setFlags(AMQP_DURABLE);
     $exchange->setName('exchange2');
     $exchange->setType('direct');
     //$exchange->declare();
     $exchange->declareExchange();
     $queue = new \AMQPQueue($channel);
     $queue->setName('series');
     $queue->setFlags(AMQP_DURABLE | AMQP_AUTODELETE);
     //$queue->declare();
     $queue->declareQueue();
     $queue->bind('exchange2', 'series');
     $channel->startTransaction();
     $message = $exchange->publish(json_encode($msg), 'series', AMQP_MANDATORY, array('content_type' => 'application/json', 'delivery_mode' => 2));
     $channel->commitTransaction();
     if (!$message) {
         throw new \SYSTEM\LOG\ERROR("Error: Message '" . $message . "' was not sent to queue.!");
     }
 }
开发者ID:webcraftmedia,项目名称:system,代码行数:22,代码来源:ConnectionAMQP.php

示例11: AMQPConnection

//Establish connection to AMQP
$connection = new AMQPConnection();
$connection->setHost('127.0.0.1');
$connection->setLogin('guest');
$connection->setPassword('guest');
$connection->connect();
//Declare Channel
$channel = new AMQPChannel($connection);
$routing_key = $severity = isset($argv[1]) && !empty($argv[1]) ? $argv[1] : 'info';
$message = implode(' ', array_slice($argv, 2));
if (empty($message)) {
    $message = 'Hello World!';
}
try {
    //Declare Exchange
    $exchange_name = 'direct_logs';
    $exchange = new AMQPExchange($channel);
    $exchange->setType(AMQP_EX_TYPE_DIRECT);
    $exchange->setName($exchange_name);
    $exchange->declareExchange();
    $queue = new AMQPQueue($channel);
    $queue->setFlags(AMQP_EXCLUSIVE);
    $queue->setName('monitor.1');
    $queue->declareQueue();
    $queue->bind($exchange_name, $routing_key);
    $exchange->publish($message, $routing_key);
    echo " [x] Sent {$severity}:{$message}", PHP_EOL;
} catch (Exception $ex) {
    print_r($ex);
}
$connection->disconnect();
开发者ID:CraryPrimitiveMan,项目名称:code-examples,代码行数:31,代码来源:emit_log_direct.php

示例12: getExchange

 /**
  * Get exchange
  *
  * @param string $name The exchange name
  *
  * @return \AMQPExchange
  */
 protected function getExchange($name)
 {
     if (isset($this->exchanges[$name])) {
         return $this->exchanges[$name];
     }
     $config = $this->getConfig('exchange', $name);
     if (null === $config) {
         throw new \InvalidArgumentException("Exchange definition '{$name}' doesn't exists.");
     }
     $connection = $this->getConnection($config['connection']);
     $this->exchanges[$name] = $exchange = new \AMQPExchange($connection['channel']);
     $exchange->setName(is_callable($config['name']) ? call_user_func($config['name']) : $config['name']);
     $exchange->setType(isset($config['type']) ? $config['type'] : 'topic');
     $exchange->setFlags(Helper\Options::toFlags($config));
     $exchange->declareExchange();
     if (isset($config['bindings'])) {
         foreach ($config['bindings'] as $binding) {
             try {
                 $this->getExchange($binding['exchange']);
             } catch (\InvalidArgumentException $e) {
             }
             $exchange->bind($binding['exchange'], $binding['routing_key'], isset($binding['arguments']) ? $binding['arguments'] : []);
         }
     }
     if (isset($config['arguments'])) {
         $exchange->setArguments($config['arguments']);
     }
     return $exchange;
 }
开发者ID:skatrych,项目名称:amqp-base,代码行数:36,代码来源:ExtAdapter.php

示例13: getExchange

 public function getExchange($name = 'default', $channelName = 'default')
 {
     $key = $channelName . '_' . $name;
     if (!isset($this->exchanges[$key])) {
         $channel = $this->getChannel($channelName);
         if (!isset($this->exchangesSettings[$name])) {
             throw new \LogicException('No settings for exchange ' . $name);
         }
         $settings = $this->exchangesSettings[$name];
         $exchange = new \AMQPExchange($channel);
         $exchange->setName($settings['name']);
         if (strpos($settings['name'], 'amq.') !== 0) {
             $queueFlags = AMQP_NOPARAM;
             if ($settings['durable']) {
                 $queueFlags |= AMQP_DURABLE;
             }
             if ($settings['passive']) {
                 $queueFlags |= AMQP_PASSIVE;
             }
             if ($settings['autoDelete']) {
                 $queueFlags |= AMQP_AUTODELETE;
             }
             $exchange->setType($this->getExchangeType($settings['type']));
             $exchange->setFlags($queueFlags);
             $exchange->declareExchange();
         }
         $this->exchanges[$key] = $exchange;
         //Warning place possible circular links
         if ($settings['to_exchanges'] !== null) {
             foreach ($settings['to_exchanges'] as $binExchangeName => $routingKeys) {
                 $bindExchange = $this->getExchange($binExchangeName, $channelName);
                 foreach ($routingKeys as $routingKey) {
                     $bindExchange->bind($exchange->getName(), $routingKey);
                 }
             }
         }
     }
     return $this->exchanges[$key];
 }
开发者ID:IvixLabs,项目名称:RabbitmqBundle,代码行数:39,代码来源:ConnectionStorage.php

示例14: declareExchange

 /**
  * Declare new exchange in AMQP broker
  *
  * @param string $name Exchange name
  * @param string $type Exchange type, see AMQP_EX_TYPE_*
  * @param bool $durable Is exchange durable
  *
  * @return bool Success flag
  *
  * @throws ConnectionException
  * @throws \AMQPException
  */
 public function declareExchange($name, $type = AMQP_EX_TYPE_DIRECT, $durable = true)
 {
     try {
         $exchange = new \AMQPExchange($this->getChannel());
         $exchange->setName($name);
         $exchange->setType($type);
         $exchange->setFlags($durable ? AMQP_DURABLE : AMQP_NOPARAM);
         return $exchange->declareExchange();
     } catch (\AMQPConnectionException $e) {
         $this->channel = null;
         throw new ConnectionException($e->getMessage(), $e->getCode(), $e);
     } catch (\AMQPException $e) {
         $this->channel = null;
         throw $e;
     }
 }
开发者ID:helminster,项目名称:imgloader,代码行数:28,代码来源:AMQPClient.php

示例15: declareExchange

 /**
  * @inheritdoc
  */
 public function declareExchange()
 {
     $this->exchange->declareExchange();
 }
开发者ID:prolic,项目名称:HumusAmqp,代码行数:7,代码来源:Exchange.php


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