コード例 #1
0
 /**
  * @group testMessage
  */
 public function testMessage()
 {
     $req = new SendMessage($this->queue);
     $req->setMessageBody($this->message);
     /**
      * @var $res SendMessageRes
      */
     $res = $req->send();
     $this->assertEquals(strtoupper(md5('{"nihao":"nihao"}')), $res->getMessageBodyMD5());
     $req = new ReceiveMessage($this->queue);
     /**
      * @var $res ReceiveMessageRes
      */
     $res = $req->send();
     $req = new DeleteMessage($this->queue);
     /**
      * @var $delRes DeleteMessageRes
      */
     $delRes = $req->setReceiptHandle($res->getReceiptHandle())->send();
     $this->assertTrue($delRes->isSuccess());
     $req = new SendMessage($this->queue);
     $req->setMessageBody($this->message);
     /**
      * @var $res SendMessageRes
      */
     $res = $req->send();
     $this->assertTrue($res->isSuccess());
     $peekReq = new PeekMessage($this->queue);
     /**
      * @var $peekRes PeekMessageRes
      */
     $peekRes = $peekReq->send();
     $this->assertTrue($peekRes->isSuccess());
     $this->assertNotEmpty($peekRes->getMessageId());
     $this->assertEquals(strtoupper(md5('{"nihao":"nihao"}')), $peekRes->getMessageBodyMD5());
     $req = new ReceiveMessage($this->queue);
     /**
      * @var $res ReceiveMessageRes
      */
     $res = $req->send();
     $cmvReq = new ChangeMessageVisibility($this->queue);
     $cmvReq->setReceiptHandle($res->getReceiptHandle());
     $cmvReq->setVisibilityTimeout(10);
     /**
      * @var $cmvRes ChangeMessageVisibilityRes
      */
     $cmvRes = $cmvReq->send();
     $this->assertTrue($cmvRes->isSuccess());
 }
コード例 #2
0
ファイル: MqsJob.php プロジェクト: baocaixiong/aliyun-mqs-lib
 /**
  * Delete the job from the queue.
  *
  * @return void
  */
 public function delete()
 {
     parent::delete();
     $req = new DeleteMessage($this->queue);
     $req->setReceiptHandle($this->job->getReceiptHandle());
     $req->send();
 }