Пример #1
0
        private static void OnError(
            Error error,
            KafkaConsumer consumer,
            IBrokerCallbacksInvoker callbacksInvoker,
            ISilverbackLogger logger)
        {
            // Ignore errors if not consuming anymore
            // (lidrdkafka randomly throws some "brokers are down" while disconnecting)
            if (!consumer.IsConnected)
            {
                return;
            }

            try
            {
                bool handled = false;

                callbacksInvoker.Invoke <IKafkaConsumerErrorCallback>(
                    handler =>
                {
                    handled &= handler.OnConsumerError(error, consumer);
                });

                if (handled)
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                logger.LogKafkaErrorHandlerError(consumer, ex);
            }

            if (error.IsFatal)
            {
                logger.LogConfluentConsumerFatalError(error, consumer);
            }
            else
            {
                logger.LogConfluentConsumerError(error, consumer);
            }
        }