public InboundConsumer(IBroker broker, IEndpoint endpoint, InboundConnectorSettings settings, Action <IEnumerable <IInboundMessage>, IServiceProvider> messagesHandler, Action <IServiceProvider> commitHandler, Action <IServiceProvider> rollbackHandler, IErrorPolicy errorPolicy, IServiceProvider serviceProvider) { _endpoint = endpoint; _settings = settings; _errorPolicy = errorPolicy; _messagesHandler = messagesHandler; _commitHandler = commitHandler; _rollbackHandler = rollbackHandler; _serviceProvider = serviceProvider; _logger = serviceProvider.GetRequiredService <ILogger <InboundConsumer> >(); _messageLogger = serviceProvider.GetRequiredService <MessageLogger>(); _inboundMessageProcessor = serviceProvider.GetRequiredService <InboundMessageProcessor>(); _consumer = broker.GetConsumer(_endpoint); Bind(); }
public MessageBatch(IEndpoint endpoint, BatchSettings settings, Action <IEnumerable <IInboundMessage>, IServiceProvider> messagesHandler, Action <IEnumerable <IOffset>, IServiceProvider> commitHandler, Action <IServiceProvider> rollbackHandler, IErrorPolicy errorPolicy, IServiceProvider serviceProvider) { _endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint)); _messagesHandler = messagesHandler ?? throw new ArgumentNullException(nameof(messagesHandler)); _commitHandler = commitHandler ?? throw new ArgumentNullException(nameof(commitHandler)); _rollbackHandler = rollbackHandler ?? throw new ArgumentNullException(nameof(rollbackHandler)); _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _inboundMessageProcessor = serviceProvider.GetRequiredService <InboundMessageProcessor>(); _errorPolicy = errorPolicy; _settings = settings; _messages = new List <IInboundMessage>(_settings.Size); if (_settings.MaxWaitTime < TimeSpan.MaxValue) { _waitTimer = new Timer(_settings.MaxWaitTime.TotalMilliseconds); _waitTimer.Elapsed += OnWaitTimerElapsed; } _logger = serviceProvider.GetRequiredService <ILogger <MessageBatch> >(); _messageLogger = serviceProvider.GetRequiredService <MessageLogger>(); }