doSend example


    public function setPort(?int $port)static
    {
        $this->port = $port;

        return $this;
    }

    public function send(MessageInterface $message): SentMessage
    {
        if (null === $this->dispatcher) {
            return $this->doSend($message);
        }

        $this->dispatcher->dispatch(new MessageEvent($message));

        try {
            $sentMessage = $this->doSend($message);
        } catch (\Throwable $error) {
            $this->dispatcher->dispatch(new FailedMessageEvent($message$error));

            throw $error;
        }

        
return $this;
    }

    public function send(RawMessage $message, Envelope $envelope = null): ?SentMessage
    {
        $message = clone $message;
        $envelope = null !== $envelope ? clone $envelope : Envelope::create($message);

        try {
            if (!$this->dispatcher) {
                $sentMessage = new SentMessage($message$envelope);
                $this->doSend($sentMessage);

                return $sentMessage;
            }

            $event = new MessageEvent($message$envelope(string) $this);
            $this->dispatcher->dispatch($event);
            if ($event->isRejected()) {
                return null;
            }

            $envelope = $event->getEnvelope();
            
Home | Imprint | This part of the site doesn't use cookies.