public ConsumerHolder(string connectionString, string endpointName, PushSettings settings, SettingsHolder settingsHolder, Func <MessageContext, Task> onMessage, Func <ErrorContext, Task <ErrorHandleResult> > onError, CriticalError criticalError, bool doNotSubscribeToEndPointQueue = false) { this.onMessage = onMessage; this.onError = onError; this.settings = settings; this.settingsHolder = settingsHolder; this.connectionString = connectionString; this.endpointName = endpointName; this.doNotSubscribeToEndPointQueue = doNotSubscribeToEndPointQueue; circuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker("kafka circuit breaker", new TimeSpan(30), ex => criticalError.Raise("Failed to receive message from Kafka.", ex)); if (consumer == null) { lock (o) { if (consumer == null) { CreateConsumer(); } } } }