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


PHP SqsClient::sendMessage方法代码示例

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


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

示例1: publish

 /**
  * Send message to sqs and trigger lambda
  *
  * @param string $message to be send via sqs
  *
  */
 public function publish($message)
 {
     // http://docs.aws.amazon.com/aws-sdk-php/v2/api/class-Aws.Sqs.SqsClient.html#_sendMessage
     $this->sqs->sendMessage(['QueueUrl' => $this->sqsQueueUrl, 'MessageBody' => $message]);
     // http://docs.aws.amazon.com/aws-sdk-php/v2/api/class-Aws.Sns.SnsClient.html#_publish
     $this->sns->publish(['TopicArn' => $this->snsTopicArn, 'Message' => 'SQS Message send', 'Subject' => 'SQS Message send']);
 }
开发者ID:mikolajprzybysz,项目名称:php-lambda-flow,代码行数:13,代码来源:Publisher.php

示例2: enqueue

 /**
  * {@inheritDoc}
  */
 public function enqueue(MessageInterface $message)
 {
     $result = $this->client->sendMessage(['QueueUrl' => $this->getUrl(), 'MessageBody' => $this->getEncoder()->encode($message), 'DelaySeconds' => $this->getMessageDelay($message)]);
     if ($result instanceof Model) {
         $message->setId($result->get('MessageId'));
     }
 }
开发者ID:ronan-gloo,项目名称:qu,代码行数:10,代码来源:SqsQueue.php

示例3: enqueue

 /**
  * @inheritDoc
  */
 public function enqueue($queueName, Message $message)
 {
     $queueUrl = $this->getQueueUrl($queueName);
     $env = new DefaultEnvelope($message);
     $data = $this->serialize($env);
     $result = $this->client->sendMessage(array('QueueUrl' => $queueUrl, 'MessageBody' => $data));
     return new SqsEnvelope($result['MessageId'], $env);
 }
开发者ID:spekkionu,项目名称:sqs-queue-driver,代码行数:11,代码来源:SqsDriver.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();
     $this->sqsClient->sendMessage(array('QueueUrl' => $this->sqsUrl, 'MessageBody' => $job->serialize(), 'VisibilityTimeout' => $delay));
     return $this;
 }
开发者ID:fguillot,项目名称:simple-queue,代码行数:16,代码来源:AwsSqsQueueAdapter.php

示例5: publish

 /**
  * {@inheritDoc}
  */
 public function publish(MessageInterface $message)
 {
     $result = $this->client->sendMessage(array('MessageBody' => $message->getBody(), 'QueueUrl' => $this->queueUrl));
     $message->addAttribute('MD5OfMessageAttributes', $result['MD5OfMessageAttributes']);
     $message->addAttribute('MD5OfMessageBody', $result['MD5OfMessageBody']);
     $message->addAttribute('MessageId', $result['MessageId']);
     return $message;
 }
开发者ID:dspacelabs,项目名称:queue,代码行数:11,代码来源:SqsQueue.php

示例6: sendSqsMessage

 /**
  * @param mixed[] $args
  * @return Result
  * @throws ExceptionInterface
  */
 private function sendSqsMessage(array $args = [])
 {
     $claimCheckSerializer = $this->configuration->getClaimCheckSerializer();
     $message = array_key_exists('MessageBody', $args) ? $args['MessageBody'] : '';
     $claimCheck = $this->storeMessageInS3($message);
     $args['MessageBody'] = $claimCheckSerializer->serialize($claimCheck);
     return $this->sqsClient->sendMessage($args);
 }
开发者ID:abacaphiliac,项目名称:aws-sdk-php-claim-check,代码行数:13,代码来源:SqsExtendedClient.php

示例7: enqueue

 /**
  * @param $jobId int
  * @param $data array
  * @param $delay int
  * @return int $messageId
  */
 public function enqueue($jobId, $data = [], $delay = 0)
 {
     $job = ['jobId' => $jobId, 'component' => $this->componentName];
     if (count($data)) {
         $job = array_merge($job, $data);
     }
     $message = $this->client->sendMessage(['QueueUrl' => $this->queueUrl, 'MessageBody' => json_encode($job), 'DelaySeconds' => $delay]);
     return $message['MessageId'];
 }
开发者ID:ErikZigo,项目名称:syrup,代码行数:15,代码来源:QueueService.php

示例8: postJob

 /**
  * Post the job to queue.
  *
  * @param Job $job The job posted to the queue.
  *
  * @return boolean whether operation succeed.
  */
 public function postJob(Job $job)
 {
     $model = $this->_client->sendMessage(['QueueUrl' => $this->url, 'MessageBody' => $this->serialize($job)]);
     if ($model !== null) {
         $job->id = $model['MessageId'];
         return true;
     } else {
         return false;
     }
 }
开发者ID:voodoo-mobile,项目名称:yii2-queue,代码行数:17,代码来源:SqsQueue.php

示例9: send

 /**
  * Sends a message to SQS using a JSON output from a given Message object
  *
  * @param Message $message  A message object to be sent to the queue
  * @return bool  returns true if message is sent successfully, otherwise false
  */
 public function send(Message $message)
 {
     try {
         // Send the message
         $this->sqs_client->sendMessage(array('QueueUrl' => $this->url, 'MessageBody' => $message->asJson()));
         return true;
     } catch (Exception $e) {
         echo 'Error sending message to queue ' . $e->getMessage();
         return false;
     }
 }
开发者ID:Avantians,项目名称:php-sqs-tutorial,代码行数:17,代码来源:Queue.php

示例10: addMessage

 /**
  * @inheritdoc
  *
  * @throws SqsException
  */
 public function addMessage($queueName, $message, $priority = null)
 {
     if (null === $priority) {
         $priority = $this->priorityHandler->getDefault();
     }
     if (empty($queueName)) {
         throw new InvalidArgumentException('Parameter queueName empty or not defined.');
     }
     if (empty($message)) {
         throw new InvalidArgumentException('Parameter message empty or not defined.');
     }
     $message = serialize($message);
     $queueUrl = $this->sqsClient->getQueueUrl(['QueueName' => $this->getQueueNameWithPrioritySuffix($queueName, $priority)])->get('QueueUrl');
     $this->sqsClient->sendMessage(['QueueUrl' => $queueUrl, 'MessageBody' => $message]);
     return $this;
 }
开发者ID:bobey,项目名称:queue-client,代码行数:21,代码来源:SQSAdapter.php

示例11: send

 /**
  * @param MessageInterface $message
  *
  * @throws \RuntimeException
  *
  * @return Model
  */
 public function send(MessageInterface $message)
 {
     $packer = $this->getPacker();
     if (!$packer) {
         throw new \RuntimeException('Packer not defined');
     }
     return $this->client->sendMessage(array('QueueUrl' => $this->getQueueUrl(), 'MessageBody' => $packer->encode($message)));
 }
开发者ID:oncesk,项目名称:sqs-wrapper,代码行数:15,代码来源:Manager.php

示例12: sendJSON

 /**
  * Send JSON data
  *
  * @link http://docs.aws.amazon.com/aws-sdk-php/v2/api/class-Aws.Sqs.SqsClient.html#_sendMessage
  * @param $data
  * @param null $delaySeconds
  * @param null $priority
  * @return bool|\Guzzle\Service\Resource\Model
  */
 public function sendJSON($data, $delaySeconds = null, $priority = null)
 {
     if (empty($this->url)) {
         return false;
     }
     $sendData = ['QueueUrl' => $this->url, 'MessageBody' => SafeJson::encode($data)];
     if ($delaySeconds != null) {
         $sendData['DelaySeconds'] = $delaySeconds;
     }
     if ($priority != null) {
         $sendData['MessageAttributes'] = ["Priority" => ['DataType' => 'Number', 'StringValue' => $priority]];
     }
     return $this->client->sendMessage($sendData);
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:23,代码来源:Sqs.php

示例13: sendMessage

 public function sendMessage($payroll, $delay = 0, $attributes = [])
 {
     $args = ["QueueUrl" => $this->getQueueUrl(), "MessageBody" => $payroll];
     if ($delay) {
         $args['DelaySeconds'] = $delay;
     }
     if ($attributes) {
         $args['MessageAttributes'] = $attributes;
     }
     $result = $this->client->sendMessage($args);
     $sent_msg = new SqsSentMessage($result->toArray());
     $md5 = md5($payroll);
     if ($result['MD5OfMessageBody'] != $md5) {
         throw new \RuntimeException("MD5 of payroll is different on sent message!");
     }
     return $sent_msg;
 }
开发者ID:oasmobile,项目名称:php-aws-wrappers,代码行数:17,代码来源:SqsQueue.php

示例14: addMessage

 /**
  * @inheritdoc
  *
  * @throws \InvalidArgumentException
  * @throws \InvalidArgumentException
  * @throws QueueAccessException
  */
 public function addMessage($queueName, $message, Priority $priority = null, $delaySeconds = 0)
 {
     if (empty($queueName)) {
         throw new \InvalidArgumentException('Queue name empty or not defined.');
     }
     if (empty($message)) {
         throw new InvalidMessageException($message, 'Message empty or not defined.');
     }
     if (null === $priority) {
         $priority = $this->priorityHandler->getDefault();
     }
     $message = serialize($message);
     try {
         $queueUrl = $this->sqsClient->getQueueUrl(['QueueName' => $this->getQueueNameWithPrioritySuffix($queueName, $priority)])->get('QueueUrl');
         $this->sqsClient->sendMessage(['QueueUrl' => $queueUrl, 'MessageBody' => $message, 'delaySeconds' => $delaySeconds]);
     } catch (SqsException $e) {
         throw new QueueAccessException('Cannot add message in queue.', 0, $e);
     }
     return $this;
 }
开发者ID:ReputationVIP,项目名称:queue-client,代码行数:27,代码来源:SQSAdapter.php

示例15: publish

 /**
  * {@inheritDoc}
  *
  * This method will either use a SNS Topic to publish a queued message or
  * straight to SQS depending on the application configuration.
  *
  * @return string
  */
 public function publish(array $message, array $options = [])
 {
     $options = $this->mergeOptions($options);
     $publishStart = microtime(true);
     // ensures that the SQS Queue and SNS Topic exist
     if (!$this->queueExists()) {
         $this->create();
     }
     if ($options['push_notifications']) {
         if (!$this->topicExists()) {
             $this->create();
         }
         $message = ['default' => $this->getNameWithPrefix(), 'sqs' => json_encode($message), 'http' => $this->getNameWithPrefix(), 'https' => $this->getNameWithPrefix()];
         $result = $this->sns->publish(['TopicArn' => $this->topicArn, 'Subject' => $this->getName(), 'Message' => json_encode($message), 'MessageStructure' => 'json']);
         $context = ['TopicArn' => $this->topicArn, 'MessageId' => $result->get('MessageId'), 'push_notifications' => $options['push_notifications'], 'publish_time' => microtime(true) - $publishStart];
         $this->log(200, "Message published to SNS", $context);
         return $result->get('MessageId');
     }
     $result = $this->sqs->sendMessage(['QueueUrl' => $this->queueUrl, 'MessageBody' => json_encode($message), 'DelaySeconds' => $options['message_delay']]);
     $context = ['QueueUrl' => $this->queueUrl, 'MessageId' => $result->get('MessageId'), 'push_notifications' => $options['push_notifications']];
     $this->log(200, "Message published to SQS", $context);
     return $result->get('MessageId');
 }
开发者ID:uecode,项目名称:qpush-bundle,代码行数:31,代码来源:AwsProvider.php


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