Esempio n. 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);
 }
Esempio n. 2
0
        public bool Handle(TBase message)
        {
            var msg = message as TDerived;

            if (msg != null)
            {
                return(_handle.Handle(msg));
            }
            return(false);
        }
        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));
        }
 private void Process()
 {
     while (!_stop)
     {
         Message message;
         while (_messageQueue.TryDequeue(out message))
         {
             _handler.Handle(message);
             _processed++;
         }
         Thread.Sleep(1);
     }
     _stopped.Set();
 }
Esempio n. 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);
        }
Esempio n. 6
0
 public bool Handle(TDerived message)
 {
     return(_handler.Handle(message));
 }
Esempio n. 7
0
 public void RegisterHandler <T>(IHandleMessage <T> handler) where T : IMessage
 {
     m_callbackDict.Add(typeof(T), (message) => handler.Handle((T)message));
 }