public virtual async Task Invoke(Envelope envelope, IEnvelopeContext context) { envelope.Attempts++; // needs to be done here. IContinuation continuation = null; try { continuation = await FindContinuation(envelope, context).ConfigureAwait(false); continuation.Execute(envelope, context); } catch (EnvelopeDeserializationException ex) { new DeserializationFailureContinuation(ex).Execute(envelope, context); } catch (AggregateException e) { e.Flatten().InnerExceptions.Each(ex => { envelope.Callback.MarkFailed(e); var message = "Failed while invoking message {0} with continuation {1}".ToFormat(envelope.Message ?? envelope, (object)continuation ?? "could not find continuation"); context.Error(envelope.CorrelationId, message, e); }); } catch (Exception e) { envelope.Callback.MarkFailed(e); // TODO -- watch this one. var message = "Failed while invoking message {0} with continuation {1}".ToFormat(envelope.Message ?? envelope, (object)continuation ?? "could not find continuation"); context.Error(envelope.CorrelationId, message, e); } }
public void Execute(Envelope envelope, IEnvelopeContext context) { context.SendFailureAcknowledgement(envelope, "Chain execution failed"); envelope.Callback.MarkFailed(_exception); context.InfoMessage(() => new MessageFailed {Envelope = envelope.ToToken(), Exception = _exception}); if (envelope.Message == null) { context.Error(envelope.CorrelationId, "Error trying to execute a message of type " + envelope.Headers[Envelope.MessageTypeKey], _exception); } else { context.Error(envelope.CorrelationId, envelope.Message.ToString(), _exception); } }
public void Execute(Envelope envelope, IEnvelopeContext context) { envelope.Message = null; // Prevent the error from throwing again. context.SendFailureAcknowledgement(envelope, "Deserialization failed"); context.Error(envelope.CorrelationId, _exception.Message, _exception); envelope.Callback.MoveToErrors(new ErrorReport(envelope, _exception)); }
public void Execute(Envelope envelope, IEnvelopeContext context) { context.SendFailureAcknowledgement(envelope, "Chain execution failed"); envelope.Callback.MarkFailed(_exception); context.InfoMessage(() => new MessageFailed { Envelope = envelope.ToToken(), Exception = _exception }); if (envelope.Message == null) { context.Error(envelope.CorrelationId, "Error trying to execute a message of type " + envelope.Headers[Envelope.MessageTypeKey], _exception); } else { context.Error(envelope.CorrelationId, envelope.Message.ToString(), _exception); } }
public void Execute(Envelope envelope, IEnvelopeContext context) { _continuations.Each(x => { try { x.Execute(envelope, context); } catch (Exception e) { context.Error(envelope.CorrelationId, "Failed trying to run continuation {0} as part of error handling".ToFormat(x), e); } }); }
public override void Execute(Envelope envelope, IEnvelopeContext context) { try { envelope.Callback.MoveToDelayedUntil(envelope.ExecutionTime.Value); context.InfoMessage(() => new DelayedEnvelopeReceived { Envelope = envelope.ToToken() }); } catch (Exception e) { envelope.Callback.MarkFailed(e); context.Error(envelope.CorrelationId, "Failed to move delayed message to the delayed message queue", e); } }
public void Execute(Envelope envelope, IEnvelopeContext context) { try { context.SendOutgoingMessages(envelope, _context.OutgoingMessages()); envelope.Callback.MarkSuccessful(); var message = new MessageSuccessful { Envelope = envelope.ToToken() }; if (!message.Envelope.IsDelayedEnvelopePollingJobRelated()) context.InfoMessage(message); } catch (Exception ex) { context.SendFailureAcknowledgement(envelope, "Sending cascading message failed: " + ex.Message); context.Error(envelope.CorrelationId, ex.Message, ex); envelope.Callback.MoveToErrors(new ErrorReport(envelope, ex)); } }
public void Execute(Envelope envelope, IEnvelopeContext context) { try { context.SendOutgoingMessages(envelope, _context.OutgoingMessages()); envelope.Callback.MarkSuccessful(); var message = new MessageSuccessful { Envelope = envelope.ToToken() }; if (!message.Envelope.IsDelayedEnvelopePollingJobRelated()) { context.InfoMessage(message); } } catch (Exception ex) { context.SendFailureAcknowledgement(envelope, "Sending cascading message failed: " + ex.Message); context.Error(envelope.CorrelationId, ex.Message, ex); envelope.Callback.MoveToErrors(new ErrorReport(envelope, ex)); } }