private function createEventListenerForStream($callback)
    {
        $logger = $this->getLogger();

        $function = function (MessageEvent $event) use ($callback, $logger) {
            $protocol = $event->getProtocolMessage();

            if ($protocol === null) {
                $logger->debug('Incompatable message: '.$event->getMessage());

                return;
            }

            $routing = $event->getMessage()->getRoutingInformation();

            call_user_func($callback, $protocol, $routing);

            return;
        };

        return $function;
    }