public function createFromConnection(Connection $connection, $exchangeName, Channel $channel = null, array $options = [])
    {
        $identity = new Identity();

        if (null === $channel) {
            $channel = $this->channelFactory->createFromConnection($connection, $identity);
        }

        if (!$this->exchangeRegistry->hasExchange($exchangeName, $channel)) {
            $exchange = $this->exchangeFactory->createNamed($exchangeName, $channel);
        } else {
            $exchange = $this->exchangeRegistry->getExchange($exchangeName, $channel);
        }

        $publisher = new Publisher(
            $identity,
            $this->eventDispatcher,
            $connection,
            $channel,
            $exchange,
            $options
        );

        return $publisher;
    }
public function createFromConnection(Connection $connection, $exchangeName, Channel $channel = null, array $options = [])
    {
        $identity = new Identity();

        if (null === $channel) {
            $channel = $this->channelFactory->createFromConnection($connection, $identity);
        }

        if (!$this->exchangeRegistry->hasExchange($exchangeName, $channel)) {
            $exchange = $this->exchangeFactory->createNamed($exchangeName, $channel);
        } else {
            $exchange = $this->exchangeRegistry->getExchange($exchangeName, $channel);
        }

        $publisher = new Publisher(
            $identity,
            $this->eventDispatcher,
            $connection,
            $channel,
            $exchange,
            $options
        );

        return $publisher;
    }
@param Connection $connection
@param string     $exchangeName
@param array      $options

@return Publisher