コード例 #1
0
        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);
            }
        }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
 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));
 }
コード例 #5
0
 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);
     }
 }
コード例 #6
0
 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));
 }
コード例 #7
0
 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);
         }
     });
 }
コード例 #8
0
 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);
     }
 }
コード例 #9
0
 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);
     }
 }
コード例 #10
0
        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));
            }
        }
コード例 #11
0
        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));
            }
        }