/// <summary> /// Инициализирует компонент ссылками на <see cref="IMessageAdapter"/>, <see cref="IHealthCheckingService"/>, /// коллекции <see cref="IMessageProcessor"/>, <see cref="IMessageProcessorAsync"/> /// </summary> /// <param name="messageAdapter">Адаптер для работы с очередью</param> /// <param name="messageProcessors">Процессоры для обработки сообщения</param> /// <param name="asyncMessageProcessors">Асинхронные процессоры для обработки сообщения</param> /// <param name="subscribeInterval">Интервал подписки</param> /// <param name="serviceHealthDependent">Признак использования диагностики</param> /// <param name="healthCheckingService">Ссылка на службу диагностики</param> /// <param name="messagingCallContextAccessor">Контейнер с параметрами вызова для сообщения</param> /// <param name="logger">Интерфейс логгирования</param> /// <exception cref="ArgumentOutOfRangeException"></exception> protected QueuePollingReactorBase( IMessageAdapter messageAdapter, IEnumerable <IMessageProcessor> messageProcessors, IEnumerable <IMessageProcessorAsync> asyncMessageProcessors, int subscribeInterval, bool?serviceHealthDependent, IHealthCheckingService healthCheckingService, IMessagingCallContextAccessor messagingCallContextAccessor, ILogger logger) { _adapter = messageAdapter; _messageProcessors = messageProcessors; _asyncMessageProcessors = asyncMessageProcessors; if (subscribeInterval <= 0) { throw new ArgumentOutOfRangeException(nameof(subscribeInterval)); } _healthCheckingService = healthCheckingService; _hasDiagnosticErrors = false; _serviceHealthDependent = serviceHealthDependent ?? false; _messagingCallContextAccessor = messagingCallContextAccessor; _logger = logger; _subscribeInterval = subscribeInterval; }
private static QueueSubscribedReactorWrapper GetReactor( bool?serviceHealthDependent = true, IMessageAdapterWithSubscribing messageAdapter = null, IHealthCheckingService healthService = null, IMessagingCallContextAccessor messagingCallContextAccessor = null) => new QueueSubscribedReactorWrapper(messageAdapter ?? Given.MessageAdapter.Please <IMessageAdapterWithSubscribing>(), 100, serviceHealthDependent, healthService ?? Mock.Of <IHealthCheckingService>(), messagingCallContextAccessor ?? Mock.Of <IMessagingCallContextAccessor>());
public QueueSubscribedReactorWrapper( IMessageAdapterWithSubscribing messageAdapter, int reconnectTimeout, bool?serviceHealthDependent, IHealthCheckingService healthCheckingService, IMessagingCallContextAccessor messagingCallContextAccessor) : base(messageAdapter, reconnectTimeout, serviceHealthDependent, healthCheckingService, messagingCallContextAccessor, Mock.Of <ILogger>()) { }
/// <inheritdoc /> public QueueSubscribeAndReplyReactor( IMessageAdapterWithSubscribing messageAdapter, IEnumerable <IRepliableMessageProcessor> messageProcessors, IEnumerable <IRepliableMessageProcessorAsync> asyncMessageProcessor, int reconnectTimeout, string pollingId, bool?serviceHealthDependent, IHealthCheckingService healthCheckingService, IMessagingCallContextAccessor messagingCallContextAccessor) : base(messageAdapter, reconnectTimeout, pollingId, serviceHealthDependent, healthCheckingService, messagingCallContextAccessor) { _messageProcessors = messageProcessors.ThrowIfNull(nameof(messageProcessors)); _asyncMessageProcessors = asyncMessageProcessor.ThrowIfNull(nameof(asyncMessageProcessor)); }
/// <summary> /// Инициализирует экземпляр класса ссылками на <see cref="IMessageAdapterFactory" />, /// <see cref="IHealthCheckingService" />, /// коллекции элементов <see cref="IProcessor" /> и <see cref="IProcessorAsync" /> /// </summary> /// <param name="messageAdapterFactory"></param> /// <param name="messageProcessors"></param> /// <param name="asyncMessageProcessors"></param> /// <param name="healthCheckingService"></param> public QueueReactorFactory( IMessageAdapterFactory messageAdapterFactory, IEnumerable <IProcessor> messageProcessors, IEnumerable <IProcessorAsync> asyncMessageProcessors, IHealthCheckingService healthCheckingService, IMessagingCallContextAccessor messagingCallContextAccessor) { _messageAdapterFactory = messageAdapterFactory.ThrowIfNull(nameof(messageAdapterFactory)); _processors = messageProcessors.ThrowIfNull(nameof(messageProcessors)); _asyncProcessors = asyncMessageProcessors.ThrowIfNull(nameof(asyncMessageProcessors)); _healthCheckingService = healthCheckingService.ThrowIfNull(nameof(healthCheckingService)); _messagingCallContextAccessor = messagingCallContextAccessor.ThrowIfNull(nameof(messagingCallContextAccessor)); LogProcessors(_processors.ToList(), _asyncProcessors.ToList()); }
/// <summary> /// Инициализирует компонент ссылками на <see cref="IMessageAdapter" />, <see cref="IHealthCheckingService" />, /// коллекции <see cref="IMessageProcessor" />, <see cref="IMessageProcessorAsync" /> /// </summary> /// <param name="messageAdapter">Адаптер для работы с очередью</param> /// <param name="messageProcessors">Процессоры для обработки сообщения</param> /// <param name="asyncMessageProcessors">Асинхронные процессоры для обработки сообщения</param> /// <param name="subscribeInterval">Интервал подписки</param> /// <param name="pollingId">Идентификатор потока для опроса</param> /// <param name="serviceHealthDependent">Признак использования диагностики</param> /// <param name="healthCheckingService">Ссылка на службу диагностики</param> /// <param name="messagingCallContextAccessor">Ссылка на объект для доступа к контексту вызова</param> /// <exception cref="ArgumentOutOfRangeException"></exception> public QueuePollingReactor( IMessageAdapter messageAdapter, IEnumerable <IMessageProcessor> messageProcessors, IEnumerable <IMessageProcessorAsync> asyncMessageProcessors, int subscribeInterval, string pollingId, bool?serviceHealthDependent, IHealthCheckingService healthCheckingService, IMessagingCallContextAccessor messagingCallContextAccessor) : base(messageAdapter, messageProcessors, asyncMessageProcessors, subscribeInterval, pollingId, serviceHealthDependent, healthCheckingService, messagingCallContextAccessor) { }
/// <summary> /// Инициализирует компонент ссылками на <see cref="IMessageAdapter" />, <see cref="IHealthCheckingService" />, /// коллекции <see cref="IMessageProcessor" />, <see cref="IMessageProcessorAsync" /> /// </summary> /// <param name="messageAdapter">Адаптер для работы с очередью</param> /// <param name="messageProcessors">Процессоры для обработки сообщения</param> /// <param name="asyncMessageProcessors">Асинхронные процессоры для обработки сообщения</param> /// <param name="subscribeInterval">Интервал подписки</param> /// <param name="pollingId">Идентификатор потока для опроса</param> /// <param name="serviceHealthDependent">Признак использования диагностики</param> /// <param name="healthCheckingService">Ссылка на службу диагностики</param> /// <param name="messagingCallContextAccessor">Ссылка на объект для доступа к контексту вызова</param> /// <exception cref="ArgumentOutOfRangeException"></exception> public QueueTransactedPollingReactor( IMessageAdapterWithTransactions messageAdapter, IEnumerable <IMessageProcessor> messageProcessors, IEnumerable <IMessageProcessorAsync> asyncMessageProcessors, int subscribeInterval, string pollingId, bool?serviceHealthDependent, IHealthCheckingService healthCheckingService, IMessagingCallContextAccessor messagingCallContextAccessor) : base(messageAdapter, messageProcessors, asyncMessageProcessors, subscribeInterval, pollingId, serviceHealthDependent, healthCheckingService, messagingCallContextAccessor) { _transactedAdapter = messageAdapter.ThrowIfNull(nameof(messageAdapter)); }
/// <summary> /// Базовый класс для реактора, работающего на основе шаблона "Наблюдатель" /// </summary> /// <exception cref="ArgumentOutOfRangeException"></exception> protected QueueSubscribedReactorBase( IMessageAdapterWithSubscribing messageAdapter, int reconnectTimeout, string pollingId, bool?serviceHealthDependent, IHealthCheckingService healthCheckingService, IMessagingCallContextAccessor messagingCallContextAccessor) { adapter = messageAdapter.ThrowIfNull(nameof(messageAdapter)); _messagingCallContextAccessor = messagingCallContextAccessor.ThrowIfNull(nameof(messagingCallContextAccessor)); _healthCheckingService = healthCheckingService.ThrowIfNull(nameof(serviceHealthDependent)); if (reconnectTimeout <= 0) { throw new ArgumentOutOfRangeException(nameof(reconnectTimeout)); } _hasDiagnosticErrors = false; _serviceHealthDependent = serviceHealthDependent ?? false; _reconnectPolling = new Polling(reconnectTimeout, pollingId); }
/// <summary> /// Инициализирует экземпляр класса ссылками на <see cref="IMessageAdapterFactory" />, /// <see cref="IHealthCheckingService" />, /// коллекции элементов <see cref="IProcessor" /> и <see cref="IProcessorAsync" /> /// </summary> /// <param name="messageAdapterFactory">Адаптер обмена сообщениями</param> /// <param name="messageProcessors">Процессоры для обработки сообщения</param> /// <param name="asyncMessageProcessors">Асинхронные процессоры для обработки сообщения</param> /// <param name="healthCheckingService">Ссылка на службу диагностики</param> /// <param name="messagingCallContextAccessor">Ссылка на объект для доступа к контексту вызова</param> /// <param name="loggerFactory">Фабрика логгирования</param> public QueueReactorFactory( IMessageAdapterFactory messageAdapterFactory, IEnumerable <IProcessor> messageProcessors, IEnumerable <IProcessorAsync> asyncMessageProcessors, IHealthCheckingService healthCheckingService, IMessagingCallContextAccessor messagingCallContextAccessor, ILoggerFactory loggerFactory) { _logger = loggerFactory.CreateLogger <QueueReactorFactory>(); _messageAdapterFactory = messageAdapterFactory; _processors = messageProcessors; _asyncProcessors = asyncMessageProcessors; _healthCheckingService = healthCheckingService; _messagingCallContextAccessor = messagingCallContextAccessor; _loggerFactory = loggerFactory; LogProcessors(); }
/// <inheritdoc /> public QueueSubscribedReactor( IMessageAdapterWithSubscribing messageAdapter, IEnumerable <IMessageProcessor> messageProcessors, IEnumerable <IMessageProcessorAsync> asyncMessageProcessor, int reconnectTimeout, bool?serviceHealthDependent, IHealthCheckingService healthCheckingService, IMessagingCallContextAccessor messagingCallContextAccessor, ILogger <QueueSubscribedReactor> logger) : base(messageAdapter, reconnectTimeout, serviceHealthDependent, healthCheckingService, messagingCallContextAccessor, logger) { _messageProcessors = messageProcessors; _asyncMessageProcessors = asyncMessageProcessor; }
/// <summary> /// Инициализирует компонент ссылками на <see cref="IMessageAdapter" />, <see cref="IHealthCheckingService" />, /// коллекции <see cref="IMessageProcessor" />, <see cref="IMessageProcessorAsync" /> /// </summary> /// <param name="messageAdapter">Адаптер для работы с очередью</param> /// <param name="messageProcessors">Процессоры для обработки сообщения</param> /// <param name="asyncMessageProcessors">Асинхронные процессоры для обработки сообщения</param> /// <param name="subscribeInterval">Интервал подписки</param> /// <param name="serviceHealthDependent">Признак использования диагностики</param> /// <param name="healthCheckingService">Ссылка на службу диагностики</param> /// <param name="messagingCallContextAccessor">Ссылка на объект для доступа к контексту вызова</param> /// <param name="logger">Интерфейс логгирования</param> /// <exception cref="ArgumentOutOfRangeException"></exception> public QueueTransactedPollingReactor( IMessageAdapterWithTransactions messageAdapter, IEnumerable <IMessageProcessor> messageProcessors, IEnumerable <IMessageProcessorAsync> asyncMessageProcessors, int subscribeInterval, bool?serviceHealthDependent, IHealthCheckingService healthCheckingService, IMessagingCallContextAccessor messagingCallContextAccessor, ILogger <QueueTransactedPollingReactor> logger) : base(messageAdapter, messageProcessors, asyncMessageProcessors, subscribeInterval, serviceHealthDependent, healthCheckingService, messagingCallContextAccessor, logger) { _logger = logger; _transactedAdapter = messageAdapter; }
/// <summary> /// Базовый класс для реактора, работающего на основе шаблона "Наблюдатель" /// </summary> /// <exception cref="ArgumentOutOfRangeException"></exception> protected QueueSubscribedReactorBase( IMessageAdapterWithSubscribing messageAdapter, int reconnectTimeout, bool?serviceHealthDependent, IHealthCheckingService healthCheckingService, IMessagingCallContextAccessor messagingCallContextAccessor, ILogger logger) { _logger = logger; adapter = messageAdapter; _messagingCallContextAccessor = messagingCallContextAccessor; _healthCheckingService = healthCheckingService; if (reconnectTimeout <= 0) { throw new ArgumentOutOfRangeException(nameof(reconnectTimeout)); } _hasDiagnosticErrors = false; _serviceHealthDependent = serviceHealthDependent ?? false; _reconnectTimeout = reconnectTimeout; }
/// <summary> /// Инициализирует компонент ссылками на <see cref="IMessageAdapter"/>, <see cref="IHealthCheckingService"/>, /// коллекции <see cref="IMessageProcessor"/>, <see cref="IMessageProcessorAsync"/> /// </summary> /// <param name="messageAdapter">Адаптер для работы с очередью</param> /// <param name="messageProcessors">Процессоры для обработки сообщения</param> /// <param name="asyncMessageProcessors">Асинхронные процессоры для обработки сообщения</param> /// <param name="subscribeInterval">Интервал подписки</param> /// <param name="pollingId">Идентификатор потока для опроса</param> /// <param name="serviceHealthDependent">Признак использования диагностики</param> /// <param name="healthCheckingService">Ссылка на службу диагностики</param> /// <param name="messagingCallContextAccessor">Контейнер с параметрами вызова для сообщения</param> /// <exception cref="ArgumentOutOfRangeException"></exception> protected QueuePollingReactorBase(IMessageAdapter messageAdapter, IEnumerable <IMessageProcessor> messageProcessors, IEnumerable <IMessageProcessorAsync> asyncMessageProcessors, int subscribeInterval, string pollingId, bool?serviceHealthDependent, IHealthCheckingService healthCheckingService, IMessagingCallContextAccessor messagingCallContextAccessor) { _adapter = messageAdapter.ThrowIfNull(nameof(messageAdapter)); _messageProcessors = messageProcessors.ThrowIfNull(nameof(messageProcessors)); _asyncMessageProcessors = asyncMessageProcessors.ThrowIfNull(nameof(asyncMessageProcessors)); if (subscribeInterval <= 0) { throw new ArgumentOutOfRangeException(nameof(subscribeInterval)); } _healthCheckingService = healthCheckingService.ThrowIfNull(nameof(serviceHealthDependent)); _hasDiagnosticErrors = false; _serviceHealthDependent = serviceHealthDependent ?? false; _messagingCallContextAccessor = messagingCallContextAccessor; _subscribePolling = new Polling(subscribeInterval, pollingId); }