public static IBasicProperties ConvertProperties(IModel channel, IIstaMessageProperties properties) { var item = channel.CreateBasicProperties(); if (properties == null) { return(item); } if (properties.IsAppIdSet) { item.AppId = properties.AppId; } if (properties.IsContentEncodingSet) { item.ContentEncoding = properties.ContentEncoding; } if (properties.IsContentTypeSet) { item.ContentType = properties.ContentType; } if (properties.IsCorrelationIdSet) { item.CorrelationId = properties.CorrelationId; } if (properties.IsExpirationSet) { item.Expiration = properties.Expiration; } if (properties.IsExternalMessageSet) { item.MessageId = properties.ExternalMessageId; } if (properties.IsReplyToSet) { item.ReplyTo = properties.ReplyTo; } if (properties.IsTypeSet) { item.Type = properties.Type; } if (properties.IsUserIdSet) { item.UserId = properties.UserId; } if (properties.IsPrioritySet) { item.Priority = (byte)properties.Priority; } if (properties.IsTimestampSet) { item.Timestamp = new AmqpTimestamp(properties.Timestamp); } item.Headers = new Dictionary <string, object>(); item.Headers["x-action"] = properties.MessageAction; item.Headers["x-type"] = properties.MessageType; if (properties.HasHeaders) { foreach (var header in properties.Headers) { item.Headers[header.Key] = header.Value; } } item.SetPersistent(properties.Persistent); return(item); }
public void Publish <T>(string exchangeName, T message, IIstaMessageProperties properties) { Publish(exchangeName, string.Empty, message, properties); }
public void Publish <T>(string exchangeName, string exchangeRoute, T message, IIstaMessageProperties properties) { var messageProperties = MessageQueueFactory.ConvertProperties(channel, properties); var messagePayload = JsonMessageSerializer.SerializeToBytes(message); channel.BasicPublish(exchangeName, exchangeRoute, false, false, messageProperties, messagePayload); }
public void Publish(string exchangeName, string exchangeRoute, string message, IIstaMessageProperties properties) { var messageProperties = MessageQueueFactory.ConvertProperties(channel, properties); var messagePayload = Encoding.UTF8.GetBytes(message); channel.BasicPublish(exchangeName, exchangeRoute, false, false, messageProperties, messagePayload); }