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


PHP AMQPChannel::basic_publish方法代码示例

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


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

示例1: publishWithAMQP

 /**
  * @param DomainMessage $domainMessage
  */
 private function publishWithAMQP(DomainMessage $domainMessage)
 {
     $payload = $domainMessage->getPayload();
     $eventClass = get_class($payload);
     $this->logger->info("publishing message with event type {$eventClass} to exchange {$this->exchange}");
     $this->channel->basic_publish($this->messageFactory->createAMQPMessage($domainMessage), $this->exchange);
 }
开发者ID:cultuurnet,项目名称:broadway-amqp,代码行数:10,代码来源:AMQPPublisher.php

示例2: publish

 /**
  * @param $queue
  * @param $message
  *
  * @return bool
  */
 public function publish($queue, $message)
 {
     $exchange = $this->getExchange($queue);
     $msg = new AMQPMessage($message, array('content_type' => 'text/plain', 'delivery_mode' => 2));
     $this->ch->basic_publish($msg, $exchange);
     return true;
 }
开发者ID:miracle84,项目名称:johnny5,代码行数:13,代码来源:RabbitMQService.php

示例3: send

 /**
  * Send a message.
  */
 public function send()
 {
     $this->getChannel()->queue_declare('hello', false, false, false, false);
     $msg = new AMQPMessage('Hello World!');
     $this->channel->basic_publish($msg, '', 'hello');
     echo ' [X] Sent "Hello World!"' . PHP_EOL;
 }
开发者ID:Rahelno,项目名称:rfront,代码行数:10,代码来源:Send.php

示例4: schedule

 /**
  * Schedule a job in the future
  *
  * @access public
  * @param  Job      $job
  * @param  DateTime $dateTime
  * @return $this
  */
 public function schedule(Job $job, DateTime $dateTime)
 {
     $now = new DateTime();
     $when = clone $dateTime;
     $delay = $when->getTimestamp() - $now->getTimestamp();
     $message = new AMQPMessage($job->serialize(), array('delivery_mode' => 2));
     $message->set('application_headers', new AMQPTable(array('x-delay' => $delay)));
     $this->channel->basic_publish($message, $this->exchange);
     return $this;
 }
开发者ID:fguillot,项目名称:simple-queue,代码行数:18,代码来源:AmqpQueueAdapter.php

示例5: testPublishConsume

 public function testPublishConsume()
 {
     $this->msg_body = 'foo bar baz äëïöü';
     $msg = new AMQPMessage($this->msg_body, array('content_type' => 'text/plain', 'delivery_mode' => 1, 'correlation_id' => 'my_correlation_id', 'reply_to' => 'my_reply_to'));
     $this->ch->basic_publish($msg, $this->exchange_name, $this->queue_name);
     $this->ch->basic_consume($this->queue_name, getmypid(), false, false, false, false, array($this, 'process_msg'));
     while (count($this->ch->callbacks)) {
         $this->ch->wait();
     }
 }
开发者ID:adridev,项目名称:php-amqplib,代码行数:10,代码来源:AbstractPublishConsumeTest.php

示例6: write

 /**
  * {@inheritDoc}
  */
 protected function write(array $record)
 {
     $data = $record["formatted"];
     $routingKey = $this->getRoutingKey($record);
     if ($this->exchange instanceof AMQPExchange) {
         $this->exchange->publish($data, $routingKey, 0, array('delivery_mode' => 2, 'content_type' => 'application/json'));
     } else {
         $this->exchange->basic_publish($this->createAmqpMessage($data), $this->exchangeName, $routingKey);
     }
 }
开发者ID:acrobat,项目名称:monolog,代码行数:13,代码来源:AmqpHandler.php

示例7: write

 /**
  *
  * {@inheritDoc}
  *
  */
 protected function write(array $record)
 {
     $data = $record["formatted"];
     $routingKey = sprintf('%s.%s', substr($record['level_name'], 0, 4), $record['channel']);
     if ($this->exchange instanceof AMQPExchange) {
         $this->exchange->publish($data, strtolower($routingKey), 0, array('delivery_mode' => 2, 'Content-type' => 'application/json'));
     } else {
         $this->exchange->basic_publish(new AMQPMessage((string) $data, array('delivery_mode' => 2, 'content_type' => 'application/json')), $this->exchangeName, strtolower($routingKey));
     }
 }
开发者ID:sapwoo,项目名称:portfolio,代码行数:15,代码来源:AmqpHandler.php

示例8: testSendFile

 public function testSendFile()
 {
     $this->msg_body = file_get_contents(__DIR__ . '/fixtures/data_1mb.bin');
     $msg = new AMQPMessage($this->msg_body, array('delivery_mode' => 1));
     $this->ch->basic_publish($msg, $this->exchange_name, $this->queue_name);
     $this->ch->basic_consume($this->queue_name, '', false, false, false, false, array($this, 'process_msg'));
     while (count($this->ch->callbacks)) {
         $this->ch->wait();
     }
 }
开发者ID:vongrad,项目名称:loanbroker,代码行数:10,代码来源:FileTransferTest.php

示例9: publish

 /**
  * @param  AMQPMessage $message
  * @param  string      $routingKey
  * @return bool
  */
 public function publish(AMQPMessage $message, $routingKey = '')
 {
     $this->getLogger()->info('amqp.publish', ['route' => $routingKey, 'value' => $message->body]);
     try {
         $this->channel->basic_publish($message, self::CHANNEL_NAME, $routingKey);
         return true;
     } catch (\Exception $e) {
         $this->getLogger()->error($e->getMessage());
         return false;
     }
 }
开发者ID:evertharmeling,项目名称:brouwkuyp-control,代码行数:16,代码来源:Manager.php

示例10: call

 /**
  * @param $n
  * @return int
  */
 public function call($n)
 {
     $this->response = null;
     $this->corr_id = uniqid();
     $msg = new AMQPMessage((string) $n, ['correlation_id' => $this->corr_id, 'reply_to' => $this->callback_queue]);
     $this->channel->basic_publish($msg, '', 'rpc_queue');
     while (!$this->response) {
         $this->channel->wait();
     }
     return intval($this->response);
 }
开发者ID:seyfer,项目名称:rabbitmq-learn,代码行数:15,代码来源:rpc_client.php

示例11: testPublishPacketSizeLongMessage

 public function testPublishPacketSizeLongMessage()
 {
     // Connection frame_max;
     $frame_max = 131072;
     // Publish 3 messages with sizes: packet size - 1, equal packet size and packet size + 1
     for ($length = $frame_max - 9; $length <= $frame_max - 7; $length++) {
         $this->msg_body = str_repeat('1', $length);
         $msg = new AMQPMessage($this->msg_body, array('content_type' => 'text/plain', 'delivery_mode' => 1, 'correlation_id' => 'my_correlation_id', 'reply_to' => 'my_reply_to'));
         $this->ch->basic_publish($msg, $this->exchange_name, $this->queue_name);
     }
 }
开发者ID:vongrad,项目名称:loanbroker,代码行数:11,代码来源:AbstractPublishConsumeTest.php

示例12: testFrameOrder

 public function testFrameOrder()
 {
     $msg = new AMQPMessage("test message");
     $this->ch->basic_publish($msg, $this->exchange_name, $this->queue_name1);
     $this->ch->basic_publish($msg, $this->exchange_name, $this->queue_name1);
     $this->ch->basic_publish($msg, $this->exchange_name, $this->queue_name2);
     $this->ch->basic_consume($this->queue_name1, "", false, true, false, false, array($this, 'process_msg1'));
     while (count($this->ch->callbacks)) {
         $this->ch->wait();
     }
 }
开发者ID:adridev,项目名称:php-amqplib,代码行数:11,代码来源:Bug40Test.php

示例13: testFrameOrder

 public function testFrameOrder()
 {
     $msg = new AMQPMessage('');
     $hdrs = new AMQPTable(array('x-foo' => 'bar'));
     $msg->set('application_headers', $hdrs);
     for ($i = 0; $i < $this->msg_count; $i++) {
         $this->ch->basic_publish($msg, $this->exchange_name, $this->queue_name);
     }
     $this->ch2->basic_consume($this->queue_name, '', false, true, false, false, array($this, 'process_msg'));
     while (count($this->ch2->callbacks)) {
         $this->ch2->wait();
     }
 }
开发者ID:CarsonF,项目名称:php-amqplib,代码行数:13,代码来源:Bug256Test.php

示例14: call

 /**
  * @param AMQPMessage $message
  * @param string      $exchange
  * @param string      $routingKey
  *
  * @return Invoker\Reply
  *
  * @throws \Exception
  */
 public function call(AMQPMessage $message, $exchange = '', $routingKey = '')
 {
     $this->enqueue($reply = new Invoker\Reply($this));
     try {
         $message->set('reply_to', $this->getReplyQueue());
         $message->set('correlation_id', $reply->id());
         $this->channel->basic_publish($message, $exchange, $routingKey);
     } catch (\Exception $e) {
         $this->dequeue($reply);
         throw $e;
     }
     return $reply;
 }
开发者ID:skolodyazhnyy,项目名称:message-bus-client,代码行数:22,代码来源:Invoker.php

示例15: handle

 /**
  * @param AMQPMessage $message
  *
  * @throws \Exception
  */
 public function handle(AMQPMessage $message)
 {
     $reply = null;
     try {
         $reply = $this->handler->handle($message);
         $this->channel->basic_ack($message->delivery_info['delivery_tag'], false);
     } catch (RequestNotSupportedException $exception) {
         $this->channel->basic_ack($message->delivery_info['delivery_tag'], false);
     } catch (\Exception $e) {
         $this->channel->basic_reject($message->delivery_info['delivery_tag'], false);
         throw $e;
     }
     if ($reply !== null) {
         $this->channel->basic_publish($reply, '', $message->get('reply_to'));
     }
 }
开发者ID:skolodyazhnyy,项目名称:message-bus-client,代码行数:21,代码来源:Consumer.php


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