public async Task Execute(IMessagingRoot root, IChannelCallback channel, Envelope envelope, IQueuedOutgoingMessages messages, DateTime utcNow) { root.MessageLogger.NoHandlerFor(envelope); foreach (var handler in _handlers) { try { await handler.Handle(envelope, root); } catch (Exception e) { root.MessageLogger.LogException(e); } } if (envelope.AckRequested) { await root.Acknowledgements.SendAcknowledgement(envelope); } await channel.Complete(envelope); envelope.MarkCompletion(false); // These two lines are important to make the message tracking work // if there is no handler root.MessageLogger.ExecutionFinished(envelope); root.MessageLogger.MessageSucceeded(envelope); }
public Task Execute(IMessagingRoot root, IChannelCallback channel, Envelope envelope, IQueuedOutgoingMessages messages, DateTime utcNow) { envelope.ExecutionTime = utcNow.Add(Delay); if (channel is IHasNativeScheduling c) { return(c.MoveToScheduledUntil(envelope, envelope.ExecutionTime.Value)); } return(root.Persistence.ScheduleJob(envelope)); }
public async Task Execute(IMessagingRoot root, IChannelCallback channel, Envelope envelope, IQueuedOutgoingMessages messages, DateTime utcNow) { try { root.MessageLogger.DiscardedEnvelope(envelope); await channel.Complete(envelope); } catch (Exception e) { root.MessageLogger.LogException(e); } }
public async Task Execute(IMessagingRoot root, IChannelCallback channel, Envelope envelope, IQueuedOutgoingMessages messages, DateTime utcNow) { // Raise a separate "alert" event message var session = root.NewContext(); await session.Schedule(envelope.Message, utcNow.AddHours(1)); await session.Send(new RescheduledAlert() { Id = envelope.Id, ExceptionText = _ex.ToString() }); }
public async Task Invoke(Envelope envelope, IChannelCallback channel) { var context = new MessageContext(_root, envelope); try { var continuation = await execute(context, envelope); await continuation.Execute(_root, channel, envelope, context, DateTime.UtcNow); } catch (Exception e) { envelope.MarkCompletion(false); // TODO -- gotta do something on the envelope to get it out of the transport // Gotta get the message out of here because it's something that // could never be handled Logger.LogException(e, envelope.Id); } }
public async Task Execute(IMessagingRoot root, IChannelCallback channel, Envelope envelope, IQueuedOutgoingMessages messages, DateTime utcNow) { try { await messages.SendAllQueuedOutgoingMessages(); await channel.Complete(envelope); root.MessageLogger.MessageSucceeded(envelope); } catch (Exception ex) { await root.Acknowledgements.SendFailureAcknowledgement(envelope, "Sending cascading message failed: " + ex.Message); root.MessageLogger.LogException(ex, envelope.Id, ex.Message); root.MessageLogger.MessageFailed(envelope, ex); await new MoveToErrorQueue(ex).Execute(root, channel, envelope, messages, utcNow); } }
public async Task Execute(IMessagingRoot root, IChannelCallback channel, Envelope envelope, IQueuedOutgoingMessages messages, DateTime utcNow) { envelope.MarkCompletion(false); await root.Acknowledgements.SendFailureAcknowledgement(envelope, $"Moved message {envelope.Id} to the Error Queue.\n{Exception}"); if (channel is IHasDeadLetterQueue c) { await c.MoveToErrors(envelope, Exception); } else { // If persistable, persist await root.Persistence.MoveToDeadLetterStorage(envelope, Exception); } root.MessageLogger.MessageFailed(envelope, Exception); root.MessageLogger.MovedToErrorQueue(envelope, Exception); }
public Task Execute(IMessagingRoot root, IChannelCallback channel, Envelope envelope, IQueuedOutgoingMessages messages, DateTime utcNow) { return(root.Pipeline.Invoke(envelope, channel)); }
public Task Execute(IMessagingRoot root, IChannelCallback channel, Envelope envelope, IQueuedOutgoingMessages messages, DateTime utcNow) { return(channel.Defer(envelope)); }