Beispiel #1
0
        private string Serialize(RmqSkypeMessage message)
        {
            var serializer = new DataContractJsonSerializer(typeof(RmqSkypeMessage));

            using (var ms = new MemoryStream())
            {
                serializer.WriteObject(ms, message);
                return(Encoding.UTF8.GetString(ms.ToArray()));
            }
        }
Beispiel #2
0
        public void PushMessage(RmqSkypeMessage skypeMessage)
        {
            var factory = new ConnectionFactory()
            {
                HostName = "messaginghost"
            };

            using (var connection = factory.CreateConnection())
            {
                using (var channel = connection.CreateModel())
                {
                    channel.QueueDeclare(skypeMessageQueue, false, false, false, null);
                    string serializedBody = Serialize(skypeMessage);
                    var    body           = Encoding.UTF8.GetBytes(serializedBody);
                    channel.BasicPublish(string.Empty, skypeMessageQueue, null, body);
                }
            }
        }