/**
  * Publishes a message
  *
  * @param PhpAmqpLib_Message_AMQPMessage $msg
  * @param string $exchange
  * @param string $routing_key
  * @param bool $mandatory
  * @param bool $immediate
  * @param null $ticket
  */
 public function basic_publish($msg, $exchange = '', $routing_key = '', $mandatory = false, $immediate = false, $ticket = null)
 {
     $pkt = new PhpAmqpLib_Wire_AMQPWriter();
     $pkt->write($this->pre_publish($exchange, $routing_key, $mandatory, $immediate, $ticket));
     $this->connection->send_content($this->channel_id, 60, 0, mb_strlen($msg->body, 'ASCII'), $msg->serialize_properties(), $msg->body, $pkt);
     if ($this->next_delivery_tag > 0) {
         $this->published_messages[$this->next_delivery_tag] = $msg;
         $this->next_delivery_tag = bcadd($this->next_delivery_tag, '1', 0);
     }
 }