Uecode\Bundle\QPushBundle\Provider\FileProvider::onMessageReceived PHP 메소드

onMessageReceived() 공개 메소드

If an earlier listener has erred or stopped propagation, this method will not fire and the Queued Message should become visible in queue again. Stops Event Propagation after removing the Message
public onMessageReceived ( Uecode\Bundle\QPushBundle\Event\MessageEvent $event ) : boolean | void
$event Uecode\Bundle\QPushBundle\Event\MessageEvent The SQS Message Event
리턴 boolean | void
    public function onMessageReceived(MessageEvent $event)
    {
        $id = $event->getMessage()->getId();
        $this->delete($id);
        $event->stopPropagation();
    }

Usage Example

예제 #1
0
 public function testOnMessageReceived()
 {
     $this->provider->create();
     $id = $this->provider->publish(['foo' => 'bar']);
     $path = substr(hash('md5', $id), 0, 3);
     $this->assertTrue(is_file($this->basePath . DIRECTORY_SEPARATOR . $this->queueHash . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $id . '.json'));
     $this->provider->onMessageReceived(new MessageEvent('test', $this->provider->receive()[0]));
     $this->assertFalse(is_file($this->basePath . DIRECTORY_SEPARATOR . $this->queueHash . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $id . '.json'));
 }