/** * Handle the message by letting the next middleware handle it. If no handler is defined for this message, then * it is published to be processed asynchronously * * @param object $message * @param callable $next */ public function handle($message, callable $next) { try { $next($message); } catch (UndefinedCallable $exception) { $this->logger->log($this->logLevel, 'No message handler found, trying to handle it asynchronously', ['type' => get_class($message)]); $this->publisher->publish($message); } }
/** * Handle a message by publishing it to a queue (always), then calling the next middleware * * {@inheritdoc} */ public function handle($message, callable $next) { $this->publisher->publish($message); $next($message); }