Exemple #1
0
        private BrokeredMessage Map(Message message)
        {
            var brokered = new BrokeredMessage(new MemoryStream(Encoding.UTF8.GetBytes(message.Body)), true);
            if (message.Label.HasValue()) brokered.Label = message.Label;
            if (message.ContentType.HasValue()) brokered.ContentType = message.ContentType;
            if (message.MessageId.HasValue()) brokered.MessageId = message.MessageId;
            if (message.SessionId.HasValue()) brokered.SessionId = message.SessionId;
            if (message.CorrelationId.HasValue()) brokered.CorrelationId = message.CorrelationId;
            if (message.To.HasValue()) brokered.To = message.To;
            if (message.ReplyTo.HasValue()) brokered.ReplyTo = message.ReplyTo;
            if (message.ReplyToSessionId.HasValue()) brokered.ReplyToSessionId = message.ReplyToSessionId;
            if (message.TimeToLive.HasValue()) brokered.TimeToLive = message.TimeToLive;
            if (message.ScheduledEnqueueTime.HasValue()) brokered.ScheduledEnqueueTimeUtc = message.ScheduledEnqueueTime;

            if (message.CustomProperties != null)
            {
                foreach (var property in message.CustomProperties)
                {
                    brokered.Properties.Add(property.Key, property.Value);
                }
            }

            return brokered;
        }
Exemple #2
0
 public void Send(Message message, string queuePath)
 {
     var client = _messagingFactory.CreateQueueClient(queuePath);
     var sender = client.MessagingFactory.CreateMessageSender(client.Path);
     sender.Send(Map(message));
 }
Exemple #3
0
 public void Publish(Message message, string topicPath)
 {
     var client = _messagingFactory.CreateTopicClient(topicPath);
     var sender = client.MessagingFactory.CreateMessageSender(client.Path);
     sender.Send(Map(message));
 }