public function produce(Message $message)
    {
        $type = $message->getType();
        $body = array('ticket' => $message->getTicket());

        try {
            $this->logger->debug(sprintf('Publish message for job %s to sonata backend', $message->getTicket()), [
                'type' => $type,
                'body' => $body
            ]);

            $queue = $this->registry->get($message->getType())->getQueue();

            $this->backendProvider->getBackend($queue)->createAndPublish($type, $body);

        } catch (\Exception $e) {
            $this->logger->error(sprintf('Failed to publish message (Error: %s)', $e->getMessage()), ['exception' => $e]);

            if (!$e instanceof \RuntimeException) {
                $e = new \RuntimeException($e->getMessage(), $e->getCode(), $e);
            }

            throw $e;
        }
    }
public function produce(Message $message)
    {
        $type = $message->getType();
        $body = array('ticket' => $message->getTicket());

        try {
            $this->logger->debug(sprintf('Publish message for job %s to sonata backend', $message->getTicket()), [
                'type' => $type,
                'body' => $body
            ]);

            $queue = $this->registry->get($message->getType())->getQueue();

            $this->backendProvider->getBackend($queue)->createAndPublish($type, $body);

        } catch (\Exception $e) {
            $this->logger->error(sprintf('Failed to publish message (Error: %s)', $e->getMessage()), ['exception' => $e]);

            if (!$e instanceof \RuntimeException) {
                $e = new \RuntimeException($e->getMessage(), $e->getCode(), $e);
            }

            throw $e;
        }
    }
public function produce ( Message $ message ) { $ type = $ message -> getType ( ) ; $ body = array ( 'ticket' => $ message -> getTicket ( ) ) ; try { $ this -> logger -> debug ( sprintf ( 'Publish message for job %s to sonata backend' , $ message -> getTicket ( ) ) , [ 'type' => $ type , 'body' => $ body ] ) ; $ queue = $ this -> registry -> get ( $ message -> getType ( ) ) -> getQueue ( ) ; $ this -> backendProvider -> getBackend ( $ queue ) -> createAndPublish ( $ type , $ body ) ; } catch ( \ Exception $ e ) { $ this -> logger -> error ( sprintf ( 'Failed to publish message (Error: %s)' , $ e -> getMessage ( ) ) , [ 'exception' => $ e ] ) ; if ( ! $ e instanceof \ RuntimeException ) { $ e = new \ RuntimeException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } throw $ e ; } }
Publishes a message to the backend.

@param Message $message
@return void
@throws \RuntimeException If publishing fails
Publishes a message to the backend .