src/Publisher/SyncPublisher.php
public function publish($data, $routingKey = '', array $headers = [])
    {
        $response = null;
        $correlationId = uniqid('', false);
        $replyTo = $this->driver->declareSimpleQueue('', Driver::QUEUE_EXCLUSIVE);

        $this->driver->publish(
            $this->exchangeName,
            new Message($data, $routingKey, $headers, $correlationId, $replyTo)
        );

        $this->driver->consume(
            $replyTo,
            function (Message $message) use ($correlationId, &$response) {
                if ($message->getCorrelationId() == $correlationId) {
                    $response = $message->getBody();
                    return QueueHandler::STOP_CONSUMING;
                }
                return QueueHandler::CONTINUE_CONSUMING;
            },
            $this->timeout
        );

        return $response;
    }
public function publish($data, $routingKey = '', array $headers = [])
    {
        $response = null;
        $correlationId = uniqid('', false);
        $replyTo = $this->driver->declareSimpleQueue('', Driver::QUEUE_EXCLUSIVE);

        $this->driver->publish(
            $this->exchangeName,
            new Message($data, $routingKey, $headers, $correlationId, $replyTo)
        );

        $this->driver->consume(
            $replyTo,
            function (Message $message) use ($correlationId, &$response) {
                if ($message->getCorrelationId() == $correlationId) {
                    $response = $message->getBody();
                    return QueueHandler::STOP_CONSUMING;
                }
                return QueueHandler::CONTINUE_CONSUMING;
            },
            $this->timeout
        );

        return $response;
    }
Publish a message on the queue

@param mixed    $data
@param string   $routingKey
@param string[] $headers

@return mixed

@throws AssertionFailedException
@throws \InvalidArgumentException