public RedisMessageTransaction(TransportMessage message, int deliveryCount, Func<Task> onCommit, Func<Task> onFail) { this.message = message; this.deliveryCount = deliveryCount; this.onCommit = onCommit; this.onFail = onFail; }
public QueueMessageTransaction(TransportMessage message, int retryCount, Func<Task> onCommit, Func<Task> onFail) { this.message = message; this.retryCount = retryCount; this.onCommit = onCommit; this.onFail = onFail; }
private TransportMessage BuildTransportMessage(Message message, Subscription subscription) { JObject jsonPayload = message.Payload is JObject ? (JObject)message.Payload : JObject.FromObject(message.Payload); var transportMessage = new TransportMessage(); // reuse existing Id or create a new one transportMessage.Id = message.Headers.GetOrDefault(MessageHeaders.Id) ?? Guid.NewGuid().ToString(); transportMessage.Name = message.Name; transportMessage.Body = jsonPayload; // copy original headers foreach (var header in message.Headers) { transportMessage.Headers[header.Key] = header.Value; } // add subscription headers transportMessage.Headers[MessageHeaders.Endpoint] = subscription.Endpoint; // destination queue / processor transportMessage.Headers[MessageHeaders.Component] = subscription.Component; //handler within the processor Console.WriteLine("Sending {0} to {1}", transportMessage.Name, subscription.Endpoint); return transportMessage; }
public async Task Send(TransportMessage message) { var endpoint = message.Headers[MessageHeaders.Endpoint]; var queue = await GetQueue(endpoint); var queueMsg = BuildCloudQueueMessage(message); await queue.AddMessageAsync(queueMsg); }
public Task Send(TransportMessage message) { var endpoint = message.Headers[MessageHeaders.Endpoint]; var queue = GetQueue(endpoint); var msg = BuildBrokeredMessage(message); return queue.SendAsync(msg); }
protected BrokeredMessage BuildBrokeredMessage(TransportMessage message) { var brokeredMessage = new BrokeredMessage(Serializer.Serialize(message.Body)); brokeredMessage.MessageId = message.Id; brokeredMessage.Label = message.Name; foreach (var header in message.Headers) { brokeredMessage.Properties[header.Key] = header.Value; } return brokeredMessage; }
protected TransportMessage BuildMessage(BrokeredMessage brokeredMessage) { var message = new TransportMessage(); message.Body = Serializer.Deserialize(brokeredMessage.GetBody<Stream>()); message.Id = brokeredMessage.MessageId; message.Name = brokeredMessage.Label; foreach (var property in brokeredMessage.Properties) { message.Headers[property.Key] = property.Value.ToString(); } return message; }
public async Task ProcessMessage(TransportMessage message) { var sw = Stopwatch.StartNew(); await this.innerDispatcher.ProcessMessage(message); sw.Stop(); var key = string.Format("{0}:{1}", message.Name, message.Headers[MessageHeaders.Component]); var counter = this.metrics.GetOrAdd(key, k => new Counter()); Interlocked.Increment(ref counter.NMessages); Interlocked.Add(ref counter.TotalMS, sw.ElapsedMilliseconds); Trace.WriteLine(string.Format("Processed {0} in {1}ms with avg {2}ms", key, sw.ElapsedMilliseconds, counter.GetAvg().TotalMilliseconds)); }
public MessageContext(TransportMessage message, IDependencyResolver resolver) { this.Message = message; this.Resolver = resolver; }
private CloudQueueMessage BuildCloudQueueMessage(TransportMessage message) { var jsonMsg = JObject.FromObject(message); var msgBytes = (Serializer.Serialize(jsonMsg) as MemoryStream).ToArray(); var queueMessage = new CloudQueueMessage(message.Id, ""); queueMessage.SetMessageContent(msgBytes); return queueMessage; }
public Task Send(TransportMessage message) { return SendMultiple(new TransportMessage[] { message }); }
public Task Send(TransportMessage message) { var endpoint = message.Headers[MessageHeaders.Endpoint]; var endpointQueue = this.bus.GetEndpointQueue(endpoint); endpointQueue.Add(new LocalMessage(message)); return Task.FromResult(true); }
public LocalMessage(TransportMessage message) { this.message = message; this.deliveryCount = 1; }
public LocalMessage(TransportMessage message) { this.message = message; this.retryCount = 0; }
public BrokeredMessageTransaction(BrokeredMessage source, TransportMessage message) { this.source = source; this.message = message; }
private static TransportMessage CreateMessageFor(string endpoint) { var msg = new TransportMessage { Id = "id1", Name = "msg", Body = new Newtonsoft.Json.Linq.JObject() }; return msg.ForEndpoint(endpoint); }