code: def _publish(self, msg):
          
          connection = self._connection.clone()
          publish = connection.ensure(self.producer, self.producer.publish,
                                      errback=self.__error_callback,
                                      max_retries=MQ_PRODUCER_MAX_RETRIES)
          publish(json.dumps(msg), exchange=self._exchange,
                  routing_key=self._routing_key, declare=[self._queue])
          logging.debug('Publisher: message sent: %s', msg)
docs: Publish, handling retries, a message in the queue.
  
          :param msg: Object which represents the message to be sent in
              the queue. Note that this object should be serializable in the
              configured format (by default JSON).