Uecode\Bundle\QPushBundle\Provider\FileProvider::onMessageReceived PHP Method

onMessageReceived() public method

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
return boolean | void
    public function onMessageReceived(MessageEvent $event)
    {
        $id = $event->getMessage()->getId();
        $this->delete($id);
        $event->stopPropagation();
    }

Usage Example

 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'));
 }