Пример #1
0
        public MessengerServer(SqlServerSettings settings, RepositoryFactory repositoryFactory)
            : base(settings)
        {
            _repositoryFactory = repositoryFactory;
            if (settings == null) throw new ArgumentNullException(nameof(settings));
            if (string.IsNullOrWhiteSpace(settings.ConnectionString)) throw new NullReferenceException("ConnectionString is not specified!");

            _jobActivator = settings.JobActivator ?? new JobActivator();
            _checkInterval = settings.CheckInterval.HasValue && settings.CheckInterval > TimeSpan.Zero
                ? settings.CheckInterval.Value
                : TimeSpan.FromSeconds(10);

            _maxProcessCount = settings.MaxProcessCount > 0 ? settings.MaxProcessCount : Environment.ProcessorCount*2;
            _messageBatchSize = settings.MessageBatchSize > 0 ? settings.MessageBatchSize : 10;

            _processNameFormat = settings.ProcessNameFormat;
            _customProcessName = settings.CustomProcessName;

            _completedMessages = settings.CompletedMessages ?? CompletedMessages.Default;

            if (_completedMessages.Archive && _completedMessages.Cleanup && _completedMessages.CleanOlderThanUtc == null)
            {
                _completedMessages.CleanOlderThanUtc = () => DateTime.Today;
            }
        }
        public TaskMonitoringService(ILogger logger, IDictionary<string, Task> tasks, RepositoryFactory factory)
        {
            _repository = factory.Create();
            _messengerService = new MessengerService(logger, factory);

            Logger = logger;
            Tasks = tasks;
        }
Пример #3
0
        public MessageProcessor(IJobActivator jobActivator, ISerializer serializer, ILogger logger, RepositoryFactory factory)
        {
            if (serializer == null) throw new ArgumentNullException(nameof(serializer));
            if (jobActivator == null) throw new ArgumentNullException(nameof(jobActivator));

            _serializer = serializer;
            _jobActivator = jobActivator;

            Repository = factory.Create();
            Service = new MessengerService(logger, factory);
            Logger = logger;
            
            Canceled = false;
        }
Пример #4
0
 public MessengerService(ILogger logger, RepositoryFactory factory)
 {
     _logger = logger;
     _repository = factory.Create();
 }