コード例 #1
0
        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);
        }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        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);
            }
        }