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


PHP AMQPExchange::setName方法代码示例

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


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

示例1: __construct

 /**
  * @param string $protocol
  * @param string $encoding
  * @param bool   $synchronous
  * @param array  $endpoint
  */
 public function __construct($protocol, $encoding, $synchronous = false, array $endpoint = [])
 {
     parent::__construct($protocol, $encoding, $synchronous, $endpoint);
     list($exchangeName, $routingKey) = array_values($this->endpoint);
     $credentials = array_filter($this->endpoint);
     $this->connection = new \AMQPConnection($credentials);
     $this->connection->connect();
     $this->channel = new \AMQPChannel($this->connection);
     $this->exchange = new \AMQPExchange($this->channel);
     $this->exchange->setName($exchangeName);
 }
开发者ID:mihai-stancu,项目名称:rpc-bundle,代码行数:17,代码来源:AmqpConnection.php

示例2: 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

示例3:

 function __construct()
 {
     $connection = new \AMQPConnection();
     $connection->connect();
     if (!$connection->isConnected()) {
         throw new \AMQPConnectionException('Rabbit is not connected');
     }
     $this->channel = new \AMQPChannel($connection);
     $this->exchange = new \AMQPExchange($this->channel);
     //$this->exchange->delete('Celium');
     $this->exchange->setName('Celium');
     $this->exchange->setType('direct');
     //$this->exchange->setFlags(\AMQP_DURABLE);
     $this->exchange->declare();
 }
开发者ID:zarincheg,项目名称:celium,代码行数:15,代码来源:Rabbit.php

示例4: send

 public function send($msg)
 {
     $ex = new \AMQPExchange($this->amqpChannel);
     $ex->setName($this->name);
     $ex->publish($msg);
     return $this;
 }
开发者ID:xezzus,项目名称:amqp-im,代码行数:7,代码来源:Message.php

示例5: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln(sprintf('Move messages from queue "%s" (vhost: "%s") to exchange "%s" with routingKey "%s" (vhost: "%s")', $input->getArgument('from_queue'), $input->getArgument('from_vhost'), $input->getArgument('to_exchange'), $input->getArgument('to_routing_key'), $input->getArgument('to_vhost')));
     $fromChannel = $this->getChannel($input->getArgument('from_connection'), $input->getArgument('from_vhost'));
     if (null === ($toConnectionName = $input->getOption('to_connection'))) {
         $toChannel = $this->getChannel($input->getArgument('from_connection'), $input->getArgument('to_vhost'));
     } else {
         $toChannel = $this->getChannel($input->getOption('to_connection'), $input->getArgument('to_vhost'));
     }
     $queue = new \AMQPQueue($fromChannel);
     $queue->setName($input->getArgument('from_queue'));
     $exchange = new \AMQPExchange($toChannel);
     $exchange->setName($input->getArgument('to_exchange'));
     $messageProvider = new PeclPackageMessageProvider($queue);
     $messagePublisher = new PeclPackageMessagePublisher($exchange);
     $options = array();
     $stack = new \Swarrot\Processor\Stack\Builder();
     if (0 !== ($max = (int) $input->getOption('max-messages'))) {
         $stack->push('Swarrot\\Processor\\MaxMessages\\MaxMessagesProcessor');
         $options['max_messages'] = $max;
     }
     $stack->push('Swarrot\\Processor\\Insomniac\\InsomniacProcessor');
     $stack->push('Swarrot\\Processor\\Ack\\AckProcessor', $messageProvider);
     $processor = $stack->resolve(new MoveProcessor($messagePublisher, $input->getArgument('to_routing_key')));
     $consumer = new Consumer($messageProvider, $processor);
     $consumer->consume($options);
 }
开发者ID:stof,项目名称:rabbit-mq-admin-toolkit,代码行数:27,代码来源:MessageMoveCommand.php

示例6: sendActivityNotice

 /**
  * Send an activity notice using AMQP
  * @param ActivityNotice $notice
  * @return bool
  */
 public function sendActivityNotice($notice)
 {
     if (!isset($notice)) {
         return false;
     }
     /** @var array $setting */
     $setting = $this->params['amqpSetting'];
     try {
         if ($this->amqpClientLibrary == "PhpAmqpLib") {
             $connection = new AMQPStreamConnection($setting['host'], $setting['port'], $setting['user'], $setting['password']);
             $channel = $connection->channel();
             $msg = new AMQPMessage(JsonHelper::encode($notice));
             $channel->basic_publish($msg, $setting['exchangeName'], $setting['routingKey']);
             $channel->close();
             $connection->close();
         } elseif ($this->amqpClientLibrary == "PECL") {
             $connection = new \AMQPConnection(['host' => $setting['host'], 'port' => $setting['port'], 'login' => $setting['user'], 'password' => $setting['password']]);
             $connection->connect();
             if ($connection->isConnected()) {
                 $channel = new \AMQPChannel($connection);
                 $exchange = new \AMQPExchange($channel);
                 $exchange->setName($setting['exchangeName']);
                 $exchange->publish(JsonHelper::encode($notice), $setting['routingKey']);
                 $connection->disconnect();
             }
         } else {
             return false;
         }
     } catch (\Exception $e) {
         return false;
     }
     return true;
 }
开发者ID:fproject,项目名称:amqp-helper,代码行数:38,代码来源:ActivityNoticeManager.php

示例7: setBroadcast

 /**
  * 广播形式写入队列
  *
  * @Author   tianyunzi
  * @DateTime 2015-08-19T18:44:42+0800
  */
 public function setBroadcast($exName, $routingKey, $value)
 {
     //创建交换机
     $ex = new \AMQPExchange($this->channel);
     $ex->setName($exName);
     //入队列
     $ex->publish($value, $routingKey, AMQP_NOPARAM, array('delivery_mode' => '2'));
 }
开发者ID:tianyunchong,项目名称:php,代码行数:14,代码来源:RabbitMQ.php

示例8: PostToExchange

 /**
  * Post a task to exchange specified in $details
  * @param AMQPConnection $connection Connection object
  * @param array $details Array of connection details
  * @param string $task JSON-encoded task
  * @param array $params AMQP message parameters
  */
 function PostToExchange($connection, $details, $task, $params)
 {
     $ch = $connection->channel;
     $xchg = new AMQPExchange($ch);
     $xchg->setName($details['exchange']);
     $success = $xchg->publish($task, $details['binding'], 0, $params);
     return $success;
 }
开发者ID:UGuarder,项目名称:celery-php,代码行数:15,代码来源:amqppeclconnector.php

示例9: 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

示例10: createExchange

 /**
  * @inheritdoc
  */
 public function createExchange(ChannelInterface $channel, $name, $type = ExchangeInterface::TYPE_DIRECT, $flags = null, array $args = [])
 {
     $delegate = new \AMQPExchange($channel->getDelegate());
     $delegate->setName($name);
     $delegate->setType($type);
     $delegate->setFlags(Exchange::convertToDelegateFlags($flags));
     $delegate->setArguments($args);
     return new Exchange($delegate, $channel);
 }
开发者ID:treehouselabs,项目名称:queue,代码行数:12,代码来源:AmqpFactory.php

示例11: getAMQPExchange

 protected function getAMQPExchange()
 {
     $connection = new \AMQPConnection(array('vhost' => 'swarrot'));
     $connection->connect();
     $channel = new \AMQPChannel($connection);
     $exchange = new \AMQPExchange($channel);
     $exchange->setName('exchange');
     return $exchange;
 }
开发者ID:Niktux,项目名称:swarrot,代码行数:9,代码来源:PeclPackageMessagePublisherTest.php

示例12: register

 /**
  * {@inheritDoc}
  */
 public function register(Container $c)
 {
     $c['amqp.connections.initializer'] = function ($c) {
         $config = $c['amqp.options'];
         $connections = array();
         if (isset($config['connections'])) {
             foreach ($config['connections'] as $name => $options) {
                 $connections[$name] = new \AMQPConnection($options);
             }
             return $connections;
         }
         if (isset($config['connection'])) {
             return array('default' => new \AMQPConnection($config['connection']));
         }
         throw new \LogicException('No connection defined');
     };
     $c['queue.factory'] = function ($c) {
         $connections = $c['amqp.connections.initializer'];
         return function ($queueName, $connectionName = null) use($connections) {
             $names = array_keys($connections);
             if (null === $connectionName) {
                 $connectionName = reset($names);
             }
             if (!array_key_exists($connectionName, $connections)) {
                 throw new \InvalidArgumentException(sprintf('Unknown connection "%s". Available: [%s]', $connectionName, implode(', ', $names)));
             }
             $connection = $connections[$connectionName];
             if (!$connection->isConnected()) {
                 $connection->connect();
             }
             $channel = new \AMQPChannel($connection);
             $queue = new \AMQPQueue($channel);
             $queue->setName($queueName);
             return $queue;
         };
     };
     $c['exchange.factory'] = function ($c) {
         $connections = $c['amqp.connections.initializer'];
         return function ($exchangeName, $connectionName = null) use($connections) {
             $names = array_keys($connections);
             if (null === $connectionName) {
                 $connectionName = reset($names);
             }
             if (!array_key_exists($connectionName, $connections)) {
                 throw new \InvalidArgumentException(sprintf('Unknown connection "%s". Available: [%s]', $connectionName, implode(', ', $names)));
             }
             $connection = $connections[$connectionName];
             if (!$connection->isConnected()) {
                 $connection->connect();
             }
             $channel = new \AMQPChannel($connection);
             $exchange = new \AMQPExchange($channel);
             $exchange->setName($exchangeName);
             return $exchange;
         };
     };
 }
开发者ID:odolbeau,项目名称:amqp-service-provider,代码行数:60,代码来源:AMQPServiceProvider.php

示例13: basic_publish

 /**
  * Publishes a message
  *
  * @param AMQPMessage $msg
  * @param string $exchange
  * @param string $routing_key
  * @param bool $mandatory
  * @param bool $immediate
  * @param null $ticket
  */
 public function basic_publish($msg, $exchange = '', $routing_key = '', $mandatory = false, $immediate = false, $ticket = null)
 {
     $flags = AMQP_NOPARAM;
     $flags += $mandatory ? AMQP_MANDATORY : 0;
     $flags += $immediate ? AMQP_IMMEDIATE : 0;
     $xchange = new \AMQPExchange($this->channel);
     $xchange->setName($exchange);
     $xchange->publish($msg->body, $routing_key, $flags, $msg->get_properties());
 }
开发者ID:remi-san,项目名称:universal-amqp,代码行数:19,代码来源:AMQPExtensionChannel.php

示例14: getExchange

 /**
  * @param string $name
  *
  * @return \AMQPExchange
  */
 protected function getExchange($name)
 {
     if (!isset($this->exchanges[$name])) {
         $exchange = new \AMQPExchange($this->getChannel());
         $exchange->setName($name);
         $this->exchanges[$name] = $exchange;
     }
     return $this->exchanges[$name];
 }
开发者ID:event-band,项目名称:band-transport-amqp-pecl,代码行数:14,代码来源:PeclAmqpDriver.php

示例15: getExchange

 /**
  * getExchange
  *
  * @param string $name
  * @param string $connection
  *
  * @return \AMQPExchange
  */
 public function getExchange($name, $connection)
 {
     if (!isset($this->exchanges[$connection][$name])) {
         if (!isset($this->exchanges[$connection])) {
             $this->exchanges[$connection] = array();
         }
         $exchange = new \AMQPExchange($this->getChannel($connection));
         $exchange->setName($name);
         $this->exchanges[$connection][$name] = $exchange;
     }
     return $this->exchanges[$connection][$name];
 }
开发者ID:antoox,项目名称:SwarrotBundle,代码行数:20,代码来源:PeclFactory.php


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