當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AMQPStreamConnection::close方法代碼示例

本文整理匯總了PHP中PhpAmqpLib\Connection\AMQPStreamConnection::close方法的典型用法代碼示例。如果您正苦於以下問題:PHP AMQPStreamConnection::close方法的具體用法?PHP AMQPStreamConnection::close怎麽用?PHP AMQPStreamConnection::close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PhpAmqpLib\Connection\AMQPStreamConnection的用法示例。


在下文中一共展示了AMQPStreamConnection::close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     //
     $queue = 'cloudstack';
     $conn = new AMQPStreamConnection(Config::get('rabbitmq.host'), Config::get('rabbitmq.port'), Config::get('rabbitmq.user'), Config::get('rabbitmq.pass'), Config::get('rabbitmq.vhost'));
     $channel = $conn->channel();
     while ($message = $channel->basic_get($queue)) {
         $messageData = json_decode($message->body);
         // Don't think we care about messages that have no status or event
         if (empty($messageData->status) || empty($messageData->event)) {
             $channel->basic_ack($message->delivery_info['delivery_tag']);
             continue;
         }
         // For the moment, we don't care about non-Completed messages.
         if (!in_array($messageData->status, ['Completed', 'Created'])) {
             $channel->basic_ack($message->delivery_info['delivery_tag']);
             continue;
         }
         if (in_array($messageData->event, ['SNAPSHOT.CREATE', 'SNAPSHOT.DELETE', 'VM.CREATE', 'VM.DESTROY'])) {
             $messageHandled = $this->parseMessage($messageData);
         } else {
             $messageHandled = true;
         }
         if ($messageHandled == true) {
             $channel->basic_ack($message->delivery_info['delivery_tag']);
         }
     }
     $channel->close();
     $conn->close();
 }
開發者ID:1stel,項目名稱:stratostack-records-generation,代碼行數:35,代碼來源:ProcessNotifications.php

示例2: __destruct

 /**
  *
  */
 public function __destruct()
 {
     if ($this->connection) {
         $this->channel->close();
         $this->connection->close();
     }
 }
開發者ID:RepoMon,項目名稱:scheduler,代碼行數:10,代碼來源:QueueClient.php

示例3: tearDown

 public function tearDown()
 {
     if ($this->ch) {
         $this->ch->exchange_delete($this->exchange_name);
         $this->ch->close();
     }
     if ($this->conn) {
         $this->conn->close();
     }
 }
開發者ID:vongrad,項目名稱:loanbroker,代碼行數:10,代碼來源:AbstractPublishConsumeTest.php

示例4: registerAction

 /**
  * @Route("/register", name="security_register")
  * @Method("POST")
  */
 public function registerAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $request = Request::createFromGlobals();
     $email = $request->request->get('email');
     $password = $request->request->get('password');
     $ico = trim($request->request->get('ico'));
     $user = new User();
     $encoder = $this->container->get('security.encoder_factory')->getEncoder($user);
     $user->setPassword($encoder->encodePassword($password, $user->getSalt()));
     $user->setEmail($email);
     $user->setIco($ico);
     $backgroundImages = ['animal', 'corn', 'farming', 'chicken'];
     shuffle($backgroundImages);
     $user->setBackgroundImage($backgroundImages[0]);
     $profileImages = ['animal', 'corn', 'farming', 'chicken'];
     shuffle($profileImages);
     $user->setProfileImage($profileImages[0]);
     $em->persist($user);
     $em->flush();
     $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
     $this->get('security.token_storage')->setToken($token);
     //rabbit MQ
     $connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
     $channel = $connection->channel();
     $channel->queue_declare('ico_queue', false, false, false, false);
     $json = json_encode(["userId" => $user->getId(), "ico" => $ico]);
     $msg = new AMQPMessage($json);
     $channel->basic_publish($msg, '', 'ico_queue');
     dump(" [x] Sent '{$ico}'\n");
     $channel->close();
     $connection->close();
     return $this->redirect($this->generateUrl('main_overview'));
 }
開發者ID:alifuk,項目名稱:mrafi,代碼行數:38,代碼來源:SecurityController.php

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

示例6: disconnect

 /**
  * Disconnects from the message broker
  */
 public function disconnect()
 {
     if ($this->connection !== null) {
         $this->channel->close();
         $this->connection->close();
     }
     return $this;
 }
開發者ID:keruald,項目名稱:broker,代碼行數:11,代碼來源:AMQPBroker.php

示例7: close

 /**
  * Closing connection to the server with possible to delete queue
  * @param bool|false $delete Set true for delete queue before closing connection
  */
 public function close($delete = false)
 {
     if ($delete) {
         $this->delete();
     }
     $this->channel->close();
     $this->connection->close();
 }
開發者ID:zarincheg,項目名稱:json-bus,代碼行數:12,代碼來源:RabbitQueue.php

示例8: forward_to_router

function forward_to_router($msg, $routing_key)
{
    $connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
    $channel = $connection->channel();
    $channel->queue_declare($routing_key, false, false, false, false);
    $channel->basic_publish($msg, '', $routing_key);
    $channel->close();
    $connection->close();
}
開發者ID:vongrad,項目名稱:loanbroker,代碼行數:9,代碼來源:receive.php

示例9: closeConnections

 /**
  * Close the channel and connections to AMQP
  *
  * @return void
  */
 public function closeConnections()
 {
     if ($this->channel) {
         $this->channel->close();
     }
     if ($this->connection) {
         $this->connection->close();
     }
 }
開發者ID:imbo,項目名稱:imbo-amqp-publisher,代碼行數:14,代碼來源:AmqpPublisher.php

示例10: closeConnection

 /**
  * @return void
  */
 public function closeConnection()
 {
     $this->closeChannel();
     if ($this->connection instanceof AbstractConnection) {
         $this->connection->close();
         $this->logger->info('Connection clossed!', ['server' => $this->server, 'port' => $this->port, 'vhost' => $this->vhost]);
     }
     $this->connection = null;
 }
開發者ID:retrinko,項目名稱:cottontail,代碼行數:12,代碼來源:PhpAmqpLibConnector.php

示例11: forward_to_translator

function forward_to_translator($msg, $routing_key)
{
    $connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
    $channel = $connection->channel();
    $channel->exchange_declare('bank_translators_exchange', 'direct', false, false, false);
    $channel->basic_publish($msg, 'bank_translators_exchange', $routing_key);
    $channel->close();
    $connection->close();
}
開發者ID:vongrad,項目名稱:loanbroker,代碼行數:9,代碼來源:receive.php

示例12: __destruct

 public function __destruct()
 {
     $this->channel->close();
     unset($this->channel);
     $this->connection->close();
     unset($this->connection);
     unset($this->replyQueueName);
     unset($this->consumerTag);
     unset($this->outputMessages);
 }
開發者ID:parallel-php,項目名稱:parallel-task,代碼行數:10,代碼來源:RabbitMQQueue.php

示例13: sendBuyServiceToRabbit

 public function sendBuyServiceToRabbit($taskId, $resourceId)
 {
     $connection = new AMQPStreamConnection(RABBIT_URL, RABBIT_PORT, RABBIT_USER, RABBIT_PASSWORD);
     $channel = $connection->channel();
     $channel->queue_declare($taskId, false, false, false, false);
     $msg = new AMQPMessage($resourceId);
     $channel->basic_publish($msg, '', $taskId);
     $channel->close();
     $connection->close();
 }
開發者ID:diegomurbanos,項目名稱:ServicesWebSocket,代碼行數:10,代碼來源:RabbitMQ.php

示例14: disconnect

 /**
  * Closes the transient connection with the AMQP broker.
  *
  * This method will close an open connection with the AMQP broker.
  *
  * @return boolean true if connection was successfully closed, false otherwise.
  */
 public function disconnect()
 {
     if (!$this->isConnected()) {
         return false;
     }
     try {
         $this->connection->close();
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
開發者ID:calcinai,項目名稱:php-amqplib-bridge,代碼行數:19,代碼來源:AMQPConnection.php

示例15: subscribe

 public function subscribe()
 {
     $connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
     $channel = $connection->channel();
     $channel->queue_declare('aggregator', false, false, false, false);
     $channel->basic_consume('aggregator', '', false, true, false, false, array($this, 'on_response'));
     echo ' [*] Waiting for messages. To exit press CTRL+C', "\n";
     while (count($channel->callbacks)) {
         $channel->wait();
     }
     $channel->close();
     $connection->close();
 }
開發者ID:vongrad,項目名稱:loanbroker,代碼行數:13,代碼來源:receive.php


注:本文中的PhpAmqpLib\Connection\AMQPStreamConnection::close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。