publish(string topic_name, message_base msg, long message_sequence_number = 0, long micros_since_epoch = 0) { byte[] bytes = BitConverter.GetBytes(msg.get_type_id()); if (BitConverter.IsLittleEndian) { Array.Reverse(bytes); } stream = new MemoryStream(); stream.Write(bytes, 0, 4); var xmlSerializer = new XmlSerializer(msg.GetType()); xmlSerializer.Serialize(stream, msg); // explicit since epoch in microseconds time for the server's requirements if (micros_since_epoch != 0 && message_sequence_number != 0) { var dictionary = new Dictionary <string, object>(); dictionary.Add("XXXXXX", message_sequence_number); props.ContentType = "X"; props.Headers = dictionary; props.Timestamp = new AmqpTimestamp(micros_since_epoch); publishing_channel.BasicPublish("", topic_name, props, stream.ToArray()); } else { publishing_channel.BasicPublish("", topic_name, null, stream.ToArray()); } // Console.WriteLine("xml size: " + stream.ToArray().Length.ToString()); }
public message_wrapper(message_base msg_) { msg = msg_; }