當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。