public OutboundBrokeredMessage(string messageId, byte[] body, IDictionary <string, object> messageContext, string destination, IBrokeredMessageBodyConverter bodyConverter) : this(messageId, body, messageContext, destination) { if (string.IsNullOrWhiteSpace(destination)) { throw new ArgumentException($"A destination is required for an {typeof(OutboundBrokeredMessage).Name}.", nameof(destination)); } _bodyConverter = bodyConverter ?? throw new ArgumentNullException(nameof(bodyConverter)); MessageContext[MessageBrokers.MessageContext.ContentType] = _bodyConverter.ContentType; if (string.IsNullOrWhiteSpace(CorrelationId)) { WithCorrelationId(Guid.NewGuid().ToString()); } }
public OutboundBrokeredMessage(string messageId, byte[] body, IDictionary <string, object> applicationProperties, string destination, IBrokeredMessageBodyConverter bodyConverter) { if (string.IsNullOrWhiteSpace(destination)) { throw new ArgumentException($"A destination is required for an {typeof(OutboundBrokeredMessage).Name}.", nameof(destination)); } ApplicationProperties = applicationProperties ?? new ConcurrentDictionary <string, object>(); MessageId = messageId; Body = body ?? throw new ArgumentNullException(nameof(body)); Destination = destination; _bodyConverter = bodyConverter ?? throw new ArgumentNullException(nameof(bodyConverter)); ApplicationProperties[MessageBrokers.ApplicationProperties.ContentType] = _bodyConverter.ContentType; if (string.IsNullOrWhiteSpace(GetCorrelationId())) { WithCorrelationId(Guid.NewGuid().ToString()); } }
internal InboundBrokeredMessage(string messageId, byte[] body, IDictionary <string, object> applicationProperties, string messageReceiverPath, IBrokeredMessageBodyConverter bodyConverter) { MessageId = messageId ?? throw new System.ArgumentNullException(nameof(messageId)); Body = body ?? throw new System.ArgumentNullException(nameof(body)); _applicationProperties = applicationProperties ?? new ConcurrentDictionary <string, object>(); MessageReceiverPath = messageReceiverPath; BodyConverter = bodyConverter ?? throw new System.ArgumentNullException(nameof(bodyConverter)); TransactionMode = GetTransactionMode(); CorrelationId = GetApplicationPropertyByKey <string>(MessageBrokers.ApplicationProperties.CorrelationId); }
public OutboundBrokeredMessage(object message, string destination, IBrokeredMessageBodyConverter bodyConverter) : this(bodyConverter.Convert(message), new Dictionary <string, object>(), destination, bodyConverter) { }
public OutboundBrokeredMessage(string messageId, object message, IDictionary <string, object> applicationProperties, string destination, IBrokeredMessageBodyConverter bodyConverter) : this(messageId, bodyConverter.Convert(message), applicationProperties, destination, bodyConverter) { }
public OutboundBrokeredMessage(byte[] body, IDictionary <string, object> applicationProperties, string destination, IBrokeredMessageBodyConverter bodyConverter) : this(null, body, applicationProperties, destination, bodyConverter) { }
public OutboundBrokeredMessage(IMessageIdGenerator messageIdGenerator, object message, IDictionary <string, object> messageContext, string destination, IBrokeredMessageBodyConverter bodyConverter) : this(messageIdGenerator, bodyConverter.Convert(message), messageContext, destination, bodyConverter) { }
public OutboundBrokeredMessage(IMessageIdGenerator messageIdGenerator, byte[] body, IDictionary <string, object> messageContext, string destination, IBrokeredMessageBodyConverter bodyConverter) : this(messageIdGenerator?.GenerateId(body).ToString(), body, messageContext, destination, bodyConverter) { }
/// <summary> /// Creates an object containing context about the message received by the message broker /// </summary> /// <param name="messageId">The id of the received message</param> /// <param name="body">The body of the received message</param> /// <param name="applicationProperties">The application properties of the received message</param> /// <param name="messageReceiverPath">The message receiver path</param> /// <param name="bodyConverter">Used to convert the message body to a strongly typed object</param> public MessageBrokerContext(string messageId, byte[] body, IDictionary <string, object> applicationProperties, string messageReceiverPath, IBrokeredMessageBodyConverter bodyConverter) { this.BrokeredMessage = new InboundBrokeredMessage(messageId, body, applicationProperties, messageReceiverPath, bodyConverter); }
/// <summary> /// Creates an object containing context about the message received by the message broker /// </summary> /// <param name="messageId">The id of the received message</param> /// <param name="body">The body of the received message</param> /// <param name="applicationProperties">The application properties of the received message</param> /// <param name="messageReceiverPath">The message receiver path</param> /// <param name="bodyConverter">Used to convert the message body to a strongly typed object</param> public MessageBrokerContext(string messageId, byte[] body, IDictionary <string, object> applicationProperties, string messageReceiverPath, CancellationToken receiverCancellationToken, IBrokeredMessageBodyConverter bodyConverter) : base(receiverCancellationToken) => BrokeredMessage = new InboundBrokeredMessage(messageId, body, applicationProperties, messageReceiverPath, bodyConverter);
internal InboundBrokeredMessage(string messageId, byte[] body, IDictionary <string, object> messageContext, string messageReceiverPath, IBrokeredMessageBodyConverter bodyConverter) { MessageId = messageId; Body = body; MessageContextImpl = messageContext ?? new ConcurrentDictionary <string, object>(); MessageReceiverPath = messageReceiverPath; BodyConverter = bodyConverter ?? new JsonBodyConverter(); CorrelationId = GetMessageContextByKey <string>(MessageBrokers.MessageContext.CorrelationId); MessageContextImpl[MessageBrokers.MessageContext.ContentType] = bodyConverter.ContentType; }
internal static OutboundBrokeredMessage AsOutboundBrokeredMessage(this OutboxMessage outboxMessage, IDictionary <string, object> appProperties, IBrokeredMessageBodyConverter brokeredMessageBodyConverter) => new OutboundBrokeredMessage(outboxMessage.MessageId, outboxMessage.Body, appProperties, outboxMessage.Destination, brokeredMessageBodyConverter);