public function publish($payload, $routingKey = null, $deliveryMode = 1)
    {

        if (empty($payload)) {
            throw new Exception('publish: payload not set.');
        }

        $channel = $this->connection->channel();

        // Exchange setup
        $this->setupExchange($this->exchangeOptions['name'], $this->exchangeOptions['type'], $channel);

        foreach ($this->queueOptions as $queueOption) {
            // Queue setup
            list($channel, ) = $this->setupQueue($queueOption['name'], $channel);

            // Bind the queue to the exchange
            $channel->queue_bind($queueOption['name'], $this->exchangeOptions['name'], $queueOption['bindingKey']);
        }

        // Routing key value can be a parameter to publishMessage() or a setting in the settings array sent
        // to the instantiation of the Message Broker object.
        $routingKey = isset($routingKey) ? $routingKey : $this->routingKey;
        $messageProperties = [
            'delivery_mode' => $deliveryMode,
        ];
        $message = new AMQPMessage($payload, $messageProperties);
        $channel->basic_publish($message, $this->exchangeOptions['name'], $routingKey);

        $channel->close();
    }