Ejemplo n.º 1
0
 public AuthWorker(
     IMessageProcessorFactory processorFactory, IQueueManager queueManager, IMessageLogger logger)
 {
     _processorFactory = processorFactory;
     _logger           = logger;
     queueManager.AddMessageConsumer(AuthSettings.AuthInputQueue, OnMessageConsume);
 }
Ejemplo n.º 2
0
 public PhotoWorker(
     IMessageProcessorFactory processorFactory, IQueueManager queueManager, IMessageLogger logger)
 {
     _processorFactory = processorFactory;
     _logger           = logger;
     queueManager.AddMessageConsumer(PhotoSettings.PhotoInputQueue, OnMessageConsume);
 }
Ejemplo n.º 3
0
 public void Init(IQueueClient queueClient,
                  IMessageProcessorFactory messageProcessorFactory,
                  ConfigurationEntry configuration)
 {
     Configuration            = configuration;
     _queueClient             = queueClient;
     _messageProcessorFactory = messageProcessorFactory;
 }
        public void Setup()
        {
            listOfCars = new List <Car>()
            {
                new Car(),
                new Car()
            };

            messageProcessorFactory = new MessageProcessorFactory();
            target = new QueueManager(messageProcessorFactory);
            target.Init(listOfCars, 20);
        }
        /// <summary>
        /// Creates instance of <see cref="MessageProcessor"/>
        /// </summary>
        /// <param name="logger">Provides logging</param>
        /// <param name="telegramBotClient">A client interface to use the Telegram Bot API</param>
        /// <param name="messageProcessorFactory">Provides the necessary message processor</param>
        /// <param name="adminIdsProvider">Provides the list of admins</param>
        /// <param name="messageTypeIdentifier">Identifies the type of message</param>
        public MessageProcessor(ILogger logger, ITelegramBotClient telegramBotClient,
                                IMessageProcessorFactory messageProcessorFactory, IAdminIdsProvider adminIdsProvider,
                                IMessageTypeIdentifier messageTypeIdentifier)
        {
            _adminIdsProvider      = adminIdsProvider;
            _messageTypeIdentifier = messageTypeIdentifier;
            _adminMessageProcessor = messageProcessorFactory.GetMessageProcessor <AdminMessageProcessor>();
            _userMessageProcessor  = messageProcessorFactory.GetMessageProcessor <UserMessageProcessor>();
            _adminIds = adminIdsProvider.AdminIds;

            adminIdsProvider.AdminListUpdatedAction += UpdateAdminIds;
        }
        public void Setup()
        {
            listOfCars = new List<Car>()
               {
                  new Car(),
                  new Car()
               };

             messageProcessorFactory = new MessageProcessorFactory();
             target = new QueueManager(messageProcessorFactory);
             target.Init(listOfCars, 20);
        }
Ejemplo n.º 7
0
 public Orchestrator(IConfigurationReader configurationReader,
                     IQueueClientFactory queueClientFactory,
                     IMessageProcessorFactory messageProcessorFactory,
                     IQueueProcessorFactory queueProcessorFactory,
                     IConfigurationChangeManager configurationChangeManager)
 {
     IsProcessing                = false;
     _configurationReader        = configurationReader;
     _queueClientFactory         = queueClientFactory;
     _messageProcessorFactory    = messageProcessorFactory;
     _queueProcessorFactory      = queueProcessorFactory;
     _configurationChangeManager = configurationChangeManager;
 }
Ejemplo n.º 8
0
        public QueueManager(IMessageProcessorFactory messageProcessorFactory)
        {
            _messageProcessorFactory = messageProcessorFactory;
             _queueLookup = new Dictionary<Car, MessageQueue>();
             _groups = new Dictionary<int, ManagedGroup>();

             UnhandledThreadException += i =>
            {
               var group = _groups[i];
               group.ExceptionCount++;
               RebuildManagedGroup(group);
            };
        }
Ejemplo n.º 9
0
        public QueueManager(IMessageProcessorFactory messageProcessorFactory)
        {
            _messageProcessorFactory = messageProcessorFactory;
            _queueLookup             = new Dictionary <Car, MessageQueue>();
            _groups = new Dictionary <int, ManagedGroup>();

            UnhandledThreadException += i =>
            {
                var group = _groups[i];
                group.ExceptionCount++;
                RebuildManagedGroup(group);
            };
        }
Ejemplo n.º 10
0
        private List <IQueueProcessor> FindConfigsToAdd(List <ConfigurationEntry> configurations,
                                                        List <IQueueProcessor> processors,
                                                        IQueueClientFactory queueClientFactory,
                                                        IMessageProcessorFactory messageProcessorFactory,
                                                        IQueueProcessorFactory queueProcessorFactory)
        {
            var toAdd = new List <IQueueProcessor>();

            foreach (var config in configurations)
            {
                if (!config.Active)
                {
                    continue;
                }

                var found = false;
                foreach (var processor in processors)
                {
                    found = ((config.Alias == processor.Configuration.Alias) &&
                             (config.AccessKey == processor.Configuration.AccessKey) &&
                             (config.AwsGatewayToken == processor.Configuration.AwsGatewayToken) &&
                             (config.AuthToken == processor.Configuration.AuthToken) &&
                             (config.QueueUrl == processor.Configuration.QueueUrl) &&
                             (config.RedriveUrl == processor.Configuration.RedriveUrl) &&
                             (config.Region == processor.Configuration.Region) &&
                             (config.SecretKey == processor.Configuration.SecretKey));
                    if (found)
                    {
                        break;
                    }
                }

                if (!found)
                {
                    Logger.Debug($"Creating new queueprocessor for queue [{config.QueueUrl}], url [{config.RedriveUrl}], alias [{config.Alias}]");
                    var queueClient = queueClientFactory.CreateClient(config);
                    queueClient.Init();
                    var queueProcessor = queueProcessorFactory.CreateQueueProcessor();
                    queueProcessor.Init(queueClient, messageProcessorFactory, config);
                    toAdd.Add(queueProcessor);
                }
            }

            return(toAdd);
        }
Ejemplo n.º 11
0
        public void ReadChanges(IConfigurationReader configurationReader,
                                List <IQueueProcessor> processors,
                                IQueueClientFactory queueClientFactory,
                                IMessageProcessorFactory messageProcessorFactory,
                                IQueueProcessorFactory queueProcessorFactory)
        {
            var configurations = configurationReader.ReadConfiguration();

            /*
             * First, create processors to add.
             */
            var toAdd = FindConfigsToAdd(configurations,
                                         processors,
                                         queueClientFactory,
                                         messageProcessorFactory,
                                         queueProcessorFactory);

            /*
             * Second, find processors to remove.
             */
            var toRemove = FindEntriesToRemove(configurations, processors);

            /*
             * Now remove those for removal and add the new ones.
             */

            foreach (var processor in toRemove)
            {
                Logger.Info($"Stopping queueprocessor for queue [{processor.Configuration.QueueUrl}], url [{processor.Configuration.RedriveUrl}], alias [{processor.Configuration.Alias}]");
                processor.Stop();
                processors.Remove(processor);
            }

            foreach (var processor in toAdd)
            {
                Logger.Info($"Starting new queueprocessor for queue [{processor.Configuration.QueueUrl}], url [{processor.Configuration.RedriveUrl}], alias [{processor.Configuration.Alias}]");
                processor.Start();
                processors.Add(processor);
            }
        }
Ejemplo n.º 12
0
 public ServerMesssageService(IFileWatcherFactory fileWatcherFactory, IMessageProcessorFactory messageProcessorFactory)
     : base(fileWatcherFactory, messageProcessorFactory)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageProcessorInvoker"/> class.
 /// </summary>
 /// <param name="processorStorage">Message processors storage.</param>
 /// <param name="processorFactory">Message processors factory.</param>
 public MessageProcessorInvoker(IMessageProcessorStorage processorStorage, IMessageProcessorFactory processorFactory)
 {
     _processorStorage = processorStorage;
     _processorFactory = processorFactory;
 }
Ejemplo n.º 14
0
 public ConnectionManager(IMessageProcessorFactory messageProcessorFactory)
 {
     _messageProcessorFactory = messageProcessorFactory;
 }
Ejemplo n.º 15
0
 public Subscriber(IOptions <RabbitSettings> options, IMessageProcessorFactory factory, Serializer <string> serializer)
 {
     _options    = options.Value;
     _factory    = factory ?? throw new ArgumentNullException(nameof(factory));
     _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
 }
Ejemplo n.º 16
0
 public LoggerWorker(IMessageProcessorFactory processorFactory, IQueueManager queueManager, ILogger <LoggerWorker> logger)
 {
     _processorFactory = processorFactory;
     _logger           = logger;
     queueManager.AddMessageConsumer(LoggerSettings.LoggerInputQueue, OnMessageConsume);
 }
Ejemplo n.º 17
0
 public BaseProcessorService(IFileWatcherFactory fileWatcherFactory, IMessageProcessorFactory messageProcessorFactory)
 {
     this.messageProcessorFactory = messageProcessorFactory;
     this.fileWatcherFactory      = fileWatcherFactory;
 }
Ejemplo n.º 18
0
 public QueueWatcherFactory(IFileWatcherFactory fileWatcherFactory, IMessageProcessorFactory messageProcessorFactory)
 {
     this.fileWatcherFactory      = fileWatcherFactory;
     this.messageProcessorFactory = messageProcessorFactory;
 }