Beispiel #1
0
 public function returnMessage(QueueMessage $message)
 {
     // re-add the message to the queue, as the first element
     $this->predis->lpush($message->getQueueId(), $message->getMessage());
     // forget we received the message
     $this->completeMessage($message);
 }
Beispiel #2
0
 public function setUp()
 {
     $this->queueUrl = "http://queue.com";
     /** @var \Mockery\Mock $urlReturn */
     $urlReturn = \Mockery::mock("Guzzle\\Service\\Resource\\Model");
     $urlReturn->shouldReceive("get")->with("QueueUrl")->andReturn($this->queueUrl)->getMock();
     $this->sqsClient = \Mockery::mock("Aws\\Sqs\\SqsClient");
     $this->sqsClient->shouldReceive("getQueueUrl")->andReturn($urlReturn);
     $this->queueMessage = \Mockery::mock("Silktide\\QueueBall\\Message\\QueueMessage");
     $this->queueMessage->shouldReceive(["getQueueId" => $this->queueId, "getReceiptId" => $this->receiptId]);
     $this->messageFactory = \Mockery::mock("Silktide\\QueueBall\\Message\\QueueMessageFactoryInterface");
 }
 /**
  * {@inheritDoc}
  * @return null|QueueMessage
  * @throws QueueException
  */
 public function createMessage($message, $queueId)
 {
     if (!is_array($message) || !isset($message["Messages"][0])) {
         return null;
     }
     $message = $message["Messages"][0];
     if (empty($message["MessageId"]) || empty($message["Body"]) || empty($message["ReceiptHandle"])) {
         throw new QueueException("SQS message has missing information");
     }
     $queueMessage = new QueueMessage();
     $queueMessage->setId($message["MessageId"]);
     $queueMessage->setMessage(json_decode($message["Body"], true));
     $queueMessage->setReceiptId($message["ReceiptHandle"]);
     $queueMessage->setQueueId($queueId);
     if (!empty($message["Attributes"]) || !empty($message["MessageAttributes"])) {
         $attributes = empty($message["Attributes"]) ? [] : $message["Attributes"];
         $attributes = array_merge($attributes, empty($message["MessageAttributes"]) ? [] : $message["MessageAttributes"]);
         $queueMessage->setAttributes($attributes);
     }
     return $queueMessage;
 }
Beispiel #4
0
 /**
  * {@inheritDoc}
  */
 public function returnMessage(QueueMessage $message)
 {
     $queueUrl = $this->getQueueUrl($message->getQueueId());
     $this->queueClient->changeMessageVisibility(["QueueUrl" => $queueUrl, "ReceiptHandle" => $message->getReceiptId(), "VisibilityTimeout" => 0]);
 }
Beispiel #5
0
 /**
  * @param QueueMessage $message
  */
 public function returnMessage(QueueMessage $message)
 {
     // add the message onto the queue again
     $this->sendMessage($message->getMessage(), $message->getQueueId());
 }