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


PHP AMQPConnection::channel方法代码示例

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


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

示例1: setUp

 protected function setUp()
 {
     $this->client = HttpClient::factory(array('host' => 'localhost'));
     $this->object = new APIClient($this->client);
     $this->conn = new \PhpAmqpLib\Connection\AMQPConnection('localhost', 5672, 'guest', 'guest', '/');
     $this->channel = $this->conn->channel();
 }
开发者ID:aashley,项目名称:RabbitMQ-Management-API-Client,代码行数:7,代码来源:APIClientTest.php

示例2: createServiceWithName

 /**
  * Create service with name
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @param $name
  * @param $requestedName
  * @return mixed
  */
 public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
 {
     $name = substr($requestedName, strlen(self::MANAGER_PREFIX));
     $config = $serviceLocator->get('config');
     $workerConfig = $config['workers'][$name];
     if (!$serviceLocator->has($workerConfig['manager']['director'])) {
         throw new \RuntimeException("Could not load {$workerConfig['manager']['director']}");
     }
     $director = $serviceLocator->get($workerConfig['manager']['director']);
     if (!$director instanceof DirectorInterface) {
         throw new \RuntimeException("Could not load {$workerConfig['manager']['director']}");
     }
     $rabbitMqSettings = isset($workerConfig['rabbitmq_settings']) ? $workerConfig['rabbitmq_settings'] : $config['rabbitmq_settings'];
     $conn = new AMQPConnection($rabbitMqSettings['host'], $rabbitMqSettings['port'], $rabbitMqSettings['username'], $rabbitMqSettings['password']);
     // Bind to the generic exchange
     $eventChannel = $conn->channel();
     $exchange = $workerConfig['manager']['general']['exchange']['name'];
     $exchangeType = $workerConfig['manager']['general']['exchange']['type'];
     $eventQueueName = $workerConfig['manager']['general']['queue']['name'];
     $routingKey = isset($workerConfig['manager']['general']['queue']['routing_key']) ? $workerConfig['manager']['general']['queue']['routing_key'] : null;
     $eventChannel->queue_declare($eventQueueName, false, true, false, false);
     $eventChannel->exchange_declare($exchange, $exchangeType, false, false, true);
     $eventChannel->queue_bind($eventQueueName, $exchange, $routingKey);
     // Bind to the one specific for the workers
     $processorQueueName = $workerConfig['manager']['worker']['queue']['name'];
     $workerExchange = $workerConfig['manager']['worker']['exchange']['name'];
     $workerExchangeType = $workerConfig['manager']['worker']['exchange']['type'];
     $workerChannel = $conn->channel();
     $workerChannel->exchange_declare($workerExchange, $workerExchangeType, false, false, false);
     $workerChannel->queue_declare($processorQueueName, false, true, false, false);
     $workerChannel->queue_bind($processorQueueName, $workerExchange);
     return new DirectedManager($conn, $eventChannel, $eventQueueName, $workerChannel, $workerExchange, $processorQueueName, $director);
 }
开发者ID:FlexShopper,项目名称:expressive-stdlib,代码行数:41,代码来源:DirectedManagerAbstractFactory.php

示例3: setupConnection

 protected function setupConnection()
 {
     Yii::trace('Connecting to broker...', __METHOD__);
     $this->connection = new AMQPConnection($this->host, $this->port, $this->user, $this->password, $this->vhost, $this->insist, $this->login_method, $this->login_response, $this->locale, $this->connection_timeout, $this->read_write_timeout, $this->context);
     $this->channel = $this->connection->channel();
     $this->channel->queue_declare($this->queue, false, true, false, false);
 }
开发者ID:highestgoodlikewater,项目名称:yii2-mailqueue,代码行数:7,代码来源:EmailTaskController.php

示例4: __construct

 private function __construct()
 {
     $this->connection = new AMQPConnection($this->connection_host, $this->connection_port, $this->connection_user, $this->connection_password);
     $this->channel = $this->connection->channel();
     $this->channel->queue_declare('task_queue_persistent', false, true, false, false);
     return $this;
 }
开发者ID:neTpyceB,项目名称:TMCms-core,代码行数:7,代码来源:Connector.php

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

示例6: getChannel

 /**
  * @return AMQPChannelannel
  */
 public function getChannel()
 {
     if (!$this->channel) {
         $this->connection = new AMQPConnection($this->settings['host'], $this->settings['port'], $this->settings['user'], $this->settings['pass'], $this->settings['vhost']);
         $this->channel = $this->connection->channel();
         register_shutdown_function(array($this, 'shutdown'));
     }
     return $this->channel;
 }
开发者ID:Neodork,项目名称:SonataNotificationBundle,代码行数:12,代码来源:AMQPBackendDispatcher.php

示例7: connect

 public function connect()
 {
     $this->logger->info("MqService connecting...");
     $this->connection = $this->connectionFactory->createConnection($this->options);
     $this->channel = $this->connection->channel();
     $this->exchangeDeclare();
     $this->isConnected = true;
     $this->logger->info("MqService connected");
 }
开发者ID:danielsan80,项目名称:async-task,代码行数:9,代码来源:RabbitMqService.php

示例8: start

 /**
  * @param string $queue
  * @param HttpRequest $httpRequest
  */
 public function start($queue, HttpRequest $httpRequest)
 {
     $this->queue = $queue;
     $this->httpRequest = $httpRequest;
     $this->connection = new AMQPConnection($this->host, $this->port, $this->user, $this->pass);
     $this->channel = $this->connection->channel();
     list(, , $consumer_count) = $this->channel->queue_declare($this->queue, false, false, false, false);
     $this->consumer_count = $consumer_count;
 }
开发者ID:alistairshaw,项目名称:ambitiousmail-relay,代码行数:13,代码来源:RabbitMQQueue.php

示例9: getChannel

 /**
  * Creates (if not yet created) and returns an AMQP channel.
  *
  * @return \PhpAmqpLib\Channel\AMQPChannel
  */
 protected function getChannel()
 {
     if (null === $this->channel) {
         $this->channel = $this->connection->channel();
         $this->channel->queue_declare($this->queueName, false, false, false, false);
         $this->channel->basic_qos(null, 1, null);
     }
     return $this->channel;
 }
开发者ID:smolowik,项目名称:concurrent-spider-bundle,代码行数:14,代码来源:Queue.php

示例10: setUp

 protected function setUp()
 {
     $this->loop = \React\EventLoop\Factory::create();
     $this->object = AsyncAPIClient::factory($this->loop, array('host' => '127.0.0.1'));
     $this->syncClientClient = HttpClient::factory(array('host' => 'localhost'));
     $this->syncClient = new APIClient($this->syncClientClient);
     $this->conn = new \PhpAmqpLib\Connection\AMQPConnection('localhost', 5672, 'guest', 'guest', '/');
     $this->channel = $this->conn->channel();
 }
开发者ID:aashley,项目名称:RabbitMQ-Management-API-Client,代码行数:9,代码来源:AsyncAPIClientTest.php

示例11: commit

 /**
  * {@inheritdoc}
  */
 public function commit()
 {
     $channel = $this->connection->channel();
     $channel->queue_declare($this->options->getQueue(), false, false, false, false);
     while (!$this->messages->isEmpty()) {
         $channel->batch_basic_publish(new AMQPMessage(serialize($this->messages->dequeue())), '', $this->options->getQueue());
     }
     $channel->publish_batch();
     $channel->close();
 }
开发者ID:palya-framework,项目名称:palya,代码行数:13,代码来源:AMQPBus.php

示例12: open

 /**
  * Open a connection with the RabbitMQ Server
  *
  * @return void
  */
 public function open()
 {
     try {
         $this->AMQPConnection = new AMQPConnection($this->host, $this->port, $this->username, $this->password, $this->vhost);
         $this->channel = $this->AMQPConnection->channel();
         $this->channel->queue_declare($this->queue_name, false, true, false, false);
         $this->channel->exchange_declare($this->queue_name, 'x-delayed-message', false, true, false, false, false, new AMQPTable(["x-delayed-type" => "direct"]));
         $this->channel->queue_bind($this->queue_name, $this->queue_name);
     } catch (Exception $e) {
         throw new Exception($e);
     }
 }
开发者ID:icombats,项目名称:tail,代码行数:17,代码来源:Connection.php

示例13: open

 /**
  * Open a connection with the RabbitMQ Server
  *
  * @return void
  */
 public function open()
 {
     try {
         $this->AMQPConnection = new AMQPConnection($this->host, $this->port, $this->username, $this->password, $this->vhost);
         $this->channel = $this->AMQPConnection->channel();
         $this->channel->queue_declare($this->queue_name, false, true, false, false);
         $this->channel->exchange_declare($this->exchange, 'direct', false, true, false);
         $this->channel->queue_bind($this->queue_name, $this->exchange);
     } catch (Exception $e) {
         throw new Exception($e);
     }
 }
开发者ID:bschmitt,项目名称:tail,代码行数:17,代码来源:Connection.php

示例14: subscribe

 public function subscribe(Consumer $consumer, ExecutionCondition $condition)
 {
     $this->consumer = $consumer;
     $this->condition = $condition;
     $channel = $this->client->channel();
     $channel->basic_consume($consumer->getConfig()->getDestination(), '', false, false, false, false, [$this, 'callback']);
     while ($condition->isValid()) {
         try {
             $channel->wait(null, null, 10);
         } catch (AMQPTimeoutException $e) {
         }
     }
 }
开发者ID:grimkirill,项目名称:queue,代码行数:13,代码来源:AmpqDriver.php

示例15: getChannel

 /**
  * getChannel
  *
  * @param string $connection
  *
  * @return AMQPChannel
  */
 protected function getChannel($connection)
 {
     if (isset($this->channels[$connection])) {
         return $this->channels[$connection];
     }
     if (!isset($this->connections[$connection])) {
         throw new \InvalidArgumentException(sprintf('Unknown connection "%s". Available: [%s]', $connection, implode(', ', array_keys($this->connections))));
     }
     if (!isset($this->channels[$connection])) {
         $this->channels[$connection] = array();
     }
     if (isset($this->connections[$connection]['ssl']) && $this->connections[$connection]['ssl']) {
         if (empty($this->connections[$connection]['ssl_options'])) {
             $ssl_opts = array('verify_peer' => true);
         } else {
             $ssl_opts = array();
             foreach ($this->connections[$connection]['ssl_options'] as $key => $value) {
                 if (!empty($value)) {
                     $ssl_opts[$key] = $value;
                 }
             }
         }
         $conn = new AMQPSSLConnection($this->connections[$connection]['host'], $this->connections[$connection]['port'], $this->connections[$connection]['login'], $this->connections[$connection]['password'], $this->connections[$connection]['vhost'], $ssl_opts);
     } else {
         $conn = new AMQPConnection($this->connections[$connection]['host'], $this->connections[$connection]['port'], $this->connections[$connection]['login'], $this->connections[$connection]['password'], $this->connections[$connection]['vhost']);
     }
     //$conn->connect();
     $this->channels[$connection] = $conn->channel();
     return $this->channels[$connection];
 }
开发者ID:antoox,项目名称:SwarrotBundle,代码行数:37,代码来源:AmqpLibFactory.php


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