src/Provider/AwsProvider.php
public function onNotification(NotificationEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (NotificationEvent::TYPE_SUBSCRIPTION == $event->getType()) {
            $topicArn   = $event->getNotification()->getMetadata()->get('TopicArn');
            $token      = $event->getNotification()->getMetadata()->get('Token');

            $this->sns->confirmSubscription([
                'TopicArn'  => $topicArn,
                'Token'     => $token
            ]);

            $context = ['TopicArn' => $topicArn];
            $this->log(200,"Subscription to SNS Confirmed", $context);

            return;
        }

        $messages = $this->receive();
        foreach ($messages as $message) {

            $messageEvent = new MessageEvent($this->name, $message);
            $dispatcher->dispatch(Events::Message($this->name), $messageEvent);
        }
    }
public function onNotification(NotificationEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (NotificationEvent::TYPE_SUBSCRIPTION == $event->getType()) {
            $topicArn   = $event->getNotification()->getMetadata()->get('TopicArn');
            $token      = $event->getNotification()->getMetadata()->get('Token');

            $this->sns->confirmSubscription([
                'TopicArn'  => $topicArn,
                'Token'     => $token
            ]);

            $context = ['TopicArn' => $topicArn];
            $this->log(200,"Subscription to SNS Confirmed", $context);

            return;
        }

        $messages = $this->receive();
        foreach ($messages as $message) {

            $messageEvent = new MessageEvent($this->name, $message);
            $dispatcher->dispatch(Events::Message($this->name), $messageEvent);
        }
    }
public function onNotification ( NotificationEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( NotificationEvent :: TYPE_SUBSCRIPTION == $ event -> getType ( ) ) { $ topicArn = $ event -> getNotification ( ) -> getMetadata ( ) -> get ( 'TopicArn' ) ; $ token = $ event -> getNotification ( ) -> getMetadata ( ) -> get ( 'Token' ) ; $ this -> sns -> confirmSubscription ( [ 'TopicArn' => $ topicArn , 'Token' => $ token ] ) ; $ context = [ 'TopicArn' => $ topicArn ] ; $ this -> log ( 200 , "Subscription to SNS Confirmed" , $ context ) ; return ; } $ messages = $ this -> receive ( ) ; foreach ( $ messages as $ message ) { $ messageEvent = new MessageEvent ( $ this -> name , $ message ) ; $ dispatcher -> dispatch ( Events :: Message ( $ this -> name ) , $ messageEvent ) ; } }
Handles SNS Notifications

For Subscription notifications, this method will automatically confirm
the Subscription request

For Message notifications, this method polls the queue and dispatches
the `{queue}.message_received` event for each message retrieved

@param NotificationEvent $event The Notification Event
@param string $eventName Name of the event
@param EventDispatcherInterface $dispatcher

@return void
Handles SNS Notifications