예제 #1
0
        public virtual void Handle(IMessageMetadataEnvelop <TMessage> msg)
        {
            _monitor.IncrementMessagesReceived();
            _log.Trace("Handler actor got message: {@Message}", msg);

            try
            {
                var handlerWithMetadata = _handler as IHandlerWithMetadata <TMessage>;
                if (handlerWithMetadata != null)
                {
                    handlerWithMetadata.Handle(msg.Message, msg.Metadata);
                }
                else
                {
                    _handler.Handle(msg.Message);
                }
            }
            catch (Exception e)
            {
                _log.Error(e, "Handler actor raised an error on message process: {@Message}", msg);

                var metadata = msg.Metadata.CreateChild(Guid.Empty,
                                                        new ProcessEntry(typeof(THandler).Name, MessageHandlingStatuses.PublishingFault, MessageHandlingStatuses.MessageProcessCasuedAnError));

                var fault = Fault.New(msg.Message, e, GetSagaId(msg.Message), typeof(THandler));

                _publisher.Publish(fault, metadata);
            }
        }
예제 #2
0
 private void Unschedule(Unschedule msg)
 {
     try
     {
         _logger.Debug("Unscheduling job {Task}", msg.Key);
         var jobKey = new JobKey(msg.Key.Name, msg.Key.Group);
         _scheduler.DeleteJob(jobKey);
         _logger.Debug("Unscheduled job {Task}", msg.Key);
         Sender.Tell(new Unscheduled(msg.Key));
     }
     catch (Exception e)
     {
         _logger.Error(e, "Error while Unscheduled job {Task}", msg.Key);
         Sender.Tell(new Failure {
             Exception = e, Timestamp = BusinessDateTime.UtcNow
         });
     }
 }
예제 #3
0
        private async Task RetryAsync(Func <Task> act, int maxCount = 3)
        {
            Exception ex;

            do
            {
                try
                {
                    await act();

                    return;
                }
                catch (Exception e)
                {
                    ex = e;
                    _log.Warn(e, "Got error on trying to execute a sql journal method, will retry");
                }
            } while (SqlAzureRetriableExceptionDetector.ShouldRetryOn(ex) && --maxCount > 0);

            _log.Error(ex, "Got fatal error trying to execute a sql journal method");
            ExceptionDispatchInfo.Capture(ex).Throw();
        }
        protected override void OnReceive(object message)
        {
            try
            {
                var messageWithMetadata = message as IMessageMetadataEnvelop;
                if (messageWithMetadata != null)
                {
                    _group.Project(messageWithMetadata.Message, messageWithMetadata.Metadata);
                }
                else
                {
                    _group.Project(message, MessageMetadata.Empty());
                }
            }
            catch (MessageProcessException ex)
            {
                _log.Error(ex, "Handler actor raised an error on message process: {@Message}", message);

                var withMetadata = message as IMessageMetadataEnvelop;
                if (withMetadata == null)
                {
                    var fault = Fault.NewGeneric(message, ex.InnerException, ex.Type, GetSagaId(message));
                    _publisher.Publish(fault);
                }
                else
                {
                    var fault = Fault.NewGeneric(withMetadata.Message, ex.InnerException, ex.Type, GetSagaId(message));

                    var metadata = withMetadata.Metadata.CreateChild(Guid.Empty,
                                                                     new ProcessEntry(Self.Path.Name,
                                                                                      "publishing fault",
                                                                                      "message process casued an error"));

                    _publisher.Publish(fault, metadata);
                }
            }
        }
예제 #5
0
 public void LogFailure(string jobName, Exception e)
 {
     _coreLogger.Error(e, "Job {JobName} got an error", jobName);
 }
 public void SchedulerError(string msg, SchedulerException cause)
 {
     _log.Error(cause, "Scheduler error {@message}", msg);
 }