public void Start() { if (_started) { return; } try { _serviceContainer.Start(); _consumerPool = new ThreadPoolConsumerPool(this, _eventChannel, _receiveTimeout) { MaximumConsumerCount = MaximumConsumerThreads, }; _consumerPool.Start(); } catch (Exception) { if (_consumerPool != null) { _consumerPool.Dispose(); } throw; } _started = true; }
public KafkaMessageConsumer( IConsumerPool consumerPool, IExceptionNotifier exceptionNotifier, IOptions <AbpKafkaOptions> options) { ConsumerPool = consumerPool; ExceptionNotifier = exceptionNotifier; Options = options.Value; Logger = NullLogger <KafkaMessageConsumer> .Instance; Callbacks = new ConcurrentBag <Func <Message <string, byte[]>, Task> >(); }
protected virtual void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { if (_consumerPool != null) { _consumerPool.Stop(); _consumerPool.Dispose(); _consumerPool = null; } if (_serviceContainer != null) { _serviceContainer.Stop(); _serviceContainer.Dispose(); _serviceContainer = null; } if (ControlBus != this) { ControlBus.Dispose(); } if (_performanceCounterConnection != null) { _performanceCounterConnection.Dispose(); _performanceCounterConnection = null; } _eventChannel = null; Endpoint = null; if (_counters != null) { _counters.Dispose(); _counters = null; } EndpointCache.Dispose(); } _disposed = true; }
public KafkaMessageConsumer( IConsumerPool consumerPool, IExceptionNotifier exceptionNotifier, IOptions <AbpKafkaOptions> options, IProducerPool producerPool, AbpAsyncTimer timer) { ConsumerPool = consumerPool; ExceptionNotifier = exceptionNotifier; ProducerPool = producerPool; Timer = timer; Options = options.Value; Logger = NullLogger <KafkaMessageConsumer> .Instance; Callbacks = new ConcurrentBag <Func <Message <string, byte[]>, Task> >(); Timer.Period = 5000; //5 sec. Timer.Elapsed = Timer_Elapsed; Timer.RunOnStart = true; }