Example #1
0
 /// <summary>
 /// Publish a message.
 /// </summary>
 /// <param name="messageType">Type of the message.</param>
 /// <param name="message">The message to publish.</param>
 /// <param name="routingKey">The routingkey to use (RabbitMQ specific).</param>
 public Task PublishMessageAsync(string messageType, object message, string routingKey)
 {
     return(Task.Run(() =>
     {
         string data = MessageSerializer.Serialize(message);
         var body = Encoding.UTF8.GetBytes(data);
         IBasicProperties properties = _model.CreateBasicProperties();
         properties.Headers = new Dictionary <string, object> {
             { "MessageType", messageType }
         };
         _model.BasicPublish(_exchange, routingKey, properties, body);
     }));
 }