예제 #1
0
 /// <summary>
 /// Handles processing the specified message with the context
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="transportMessage">The transport message.</param>
 /// <returns></returns>
 public bool Handle(IMessageContext context, IReceivedMessageInternal transportMessage)
 {
     using (var heartBeat = _heartBeatWorkerFactory.Create(context))
     {
         try
         {
             _methodToRun.Handle(transportMessage, context.WorkerNotification);
             _commitMessage.Commit(context);
             return(true);
         }
         // ReSharper disable once UncatchableException
         catch (ThreadAbortException)
         {
             heartBeat.Stop();
             throw;
         }
         catch (OperationCanceledException)
         {
             heartBeat.Stop();
             throw;
         }
         catch (Exception exception)
         {
             heartBeat.Stop();
             _messageExceptionHandler.Handle(transportMessage, context, exception);
         }
     }
     return(false);
 }
예제 #2
0
        public bool Handle(TBase message)
        {
            var msg = message as TDerived;

            if (msg != null)
            {
                return(_handle.Handle(msg));
            }
            return(false);
        }
예제 #3
0
        public bool Handle(Message message)
        {
            var alertableMessage = message as IAlertable;

            if (alertableMessage != null && !_threshold.IsWithinThreshold(alertableMessage.Value))
            {
                _bus.Publish(new NeedToTakeAction(message));
            }

            return(_handler.Handle(message));
        }
예제 #4
0
 private void Process()
 {
     while (!_stop)
     {
         Message message;
         while (_messageQueue.TryDequeue(out message))
         {
             _handler.Handle(message);
             _processed++;
         }
         Thread.Sleep(1);
     }
     _stopped.Set();
 }
예제 #5
0
        public bool Handle(Message message)
        {
            var ttl = message as IHaveTimeToLive;

            if (ttl != null)
            {
                if (ttl.TimeToLive > DateTime.UtcNow)
                {
                    return(_handler.Handle(message));
                }
                else
                {
                    Console.WriteLine("Dropping message due to ttl");
                }
            }

            return(true);
        }
예제 #6
0
 public bool Handle(TDerived message)
 {
     return(_handler.Handle(message));
 }
예제 #7
0
 public void RegisterHandler <T>(IHandleMessage <T> handler) where T : IMessage
 {
     m_callbackDict.Add(typeof(T), (message) => handler.Handle((T)message));
 }