예제 #1
0
    /**
     * Test SQS methods
     *
     * @return void
     */
    public function testSqs()
    {
        try {
            $queue_url = $this->_amazon->create($this->_queue_name, 45);
            $timeout = $this->_amazon->getAttribute($queue_url, 'VisibilityTimeout');
            $this->assertEquals(45, $timeout, 'VisibilityTimeout attribute is not 45');

            $test_msg = 'this is a test';
            $this->_amazon->send($queue_url, $test_msg);

            $messages = $this->_amazon->receive($queue_url);

            foreach ($messages as $message) {
                $this->assertEquals($test_msg, $message['body']);
            }

            foreach ($messages as $message) {
                $result = $this->_amazon->deleteMessage($queue_url, $message['handle']);
                $this->assertTrue($result, 'Message was not deleted');
            }

            $count = $this->_amazon->count($queue_url);
            $this->assertEquals(0, $count);

            $this->_amazon->delete($queue_url);
        } catch (\Exception $e) {
            $this->fail($e->getMessage());
        }
    }
예제 #2
0
 /**
  * Delete the specified message from the specified queue.
  *
  * @param  string $queueId
  * @param  Zend_Cloud_QueueService_Message $message
  * @param  array  $options
  * @return void
  */
 public function deleteMessage($queueId, $message, $options = null)
 {
     try {
         if ($message instanceof Zend_Cloud_QueueService_Message) {
             $message = $message->getMessage();
         }
         $messageId = $message['handle'];
         return $this->_sqs->deleteMessage($queueId, $messageId);
     } catch (Zend_Service_Amazon_Exception $e) {
         throw new Zend_Cloud_QueueService_Exception('Error on deleting a message: ' . $e->getMessage(), $e->getCode(), $e);
     }
 }
예제 #3
0
function sqs_delete_message($access_key_id, $secret_access_key, $queue_url, $handle)
{
    $result = FALSE;
    if ($access_key_id && $secret_access_key && $queue_url && $handle) {
        try {
            $sqs = new Zend_Service_Amazon_Sqs($access_key_id, $secret_access_key);
            $result = $sqs->deleteMessage($queue_url, $handle);
        } catch (Exception $ex) {
            // ignored, $result will be false
        }
    }
    return $result;
}