public function invoke(Envelope $envelope, Queue $queue)
    {
        try {
            $this->dispatcher->dispatch(BernardEvents::INVOKE, new EnvelopeEvent($envelope, $queue));

            $receiver = $this->router->route($envelope);
            $receiver->receive($envelope->getMessage());

            // We successfully processed the message.
            $queue->acknowledge($envelope);

            $this->dispatcher->dispatch(BernardEvents::ACKNOWLEDGE, new EnvelopeEvent($envelope, $queue));
        } catch (\Throwable $error) {
            $this->rejectDispatch($error, $envelope, $queue);
        } catch (\Exception $exception) {
            $this->rejectDispatch($exception, $envelope, $queue);
        }
    }
public function invoke(Envelope $envelope, Queue $queue)
    {
        try {
            $this->dispatcher->dispatch(BernardEvents::INVOKE, new EnvelopeEvent($envelope, $queue));

            $receiver = $this->router->route($envelope);
            $receiver->receive($envelope->getMessage());

            // We successfully processed the message.
            $queue->acknowledge($envelope);

            $this->dispatcher->dispatch(BernardEvents::ACKNOWLEDGE, new EnvelopeEvent($envelope, $queue));
        } catch (\Throwable $error) {
            $this->rejectDispatch($error, $envelope, $queue);
        } catch (\Exception $exception) {
            $this->rejectDispatch($exception, $envelope, $queue);
        }
    }
public function invoke ( Envelope $ envelope , Queue $ queue ) { try { $ this -> dispatcher -> dispatch ( BernardEvents :: INVOKE , new EnvelopeEvent ( $ envelope , $ queue ) ) ; $ receiver = $ this -> router -> route ( $ envelope ) ; $ receiver -> receive ( $ envelope -> getMessage ( ) ) ; // We successfully processed the message. $ queue -> acknowledge ( $ envelope ) ; $ this -> dispatcher -> dispatch ( BernardEvents :: ACKNOWLEDGE , new EnvelopeEvent ( $ envelope , $ queue ) ) ; } catch ( \ Throwable $ error ) { $ this -> rejectDispatch ( $ error , $ envelope , $ queue ) ; } catch ( \ Exception $ exception ) { $ this -> rejectDispatch ( $ exception , $ envelope , $ queue ) ; } }
Until there is a real extension point to doing invoked stuff, this can be used
by wrapping the invoke method.

@param Envelope $envelope
@param Queue    $queue

@throws \Exception
@throws \Throwable
Until there is a real extension point to doing invoked stuff this can be used by wrapping the invoke method .