Beispiel #1
0
 public WorkerPoolFeeder(
     IConsumer consumer,
     IConsumerWorkerPool workerPool,
     ILogHandler logHandler)
 {
     this.consumer   = consumer;
     this.workerPool = workerPool;
     this.logHandler = logHandler;
 }
Beispiel #2
0
 public MessageConsumer(
     IKafkaConsumer consumer,
     IConsumerWorkerPool workerPool,
     ILogHandler logHandler)
 {
     this.workerPool = workerPool;
     this.logHandler = logHandler;
     this.consumer   = consumer;
 }
Beispiel #3
0
 public MessageConsumer(
     IConsumerClient consumerClient,
     IConsumerWorkerPool workerPool,
     ConsumerSetting configuration,
     ILogHandler logHandler)
 {
     this.workerPool     = workerPool;
     this.configuration  = configuration;
     this.logHandler     = logHandler;
     this.consumerClient = consumerClient;
 }
 public MessageConsumer(
     IConsumer <byte[], byte[]> consumer,
     KafkaConsumer kafkaConsumer,
     IConsumerWorkerPool workerPool,
     ConsumerConfiguration configuration,
     ILogHandler logHandler)
 {
     this.workerPool    = workerPool;
     this.configuration = configuration;
     this.logHandler    = logHandler;
     this.consumer      = consumer;
     this.kafkaConsumer = kafkaConsumer;
 }
Beispiel #5
0
        public ConsumerManager(
            IConsumer consumer,
            IConsumerWorkerPool consumerWorkerPool,
            IWorkerPoolFeeder feeder,
            ILogHandler logHandler)
        {
            this.logHandler = logHandler;
            this.Consumer   = consumer;
            this.WorkerPool = consumerWorkerPool;
            this.Feeder     = feeder;

            this.Consumer.OnPartitionsAssigned((_, partitions) => this.OnPartitionAssigned(partitions));
            this.Consumer.OnPartitionsRevoked((_, partitions) => this.OnPartitionRevoked(partitions));
        }
        public KafkaConsumer(
            ConsumerConfiguration configuration,
            IConsumerManager consumerManager,
            ILogHandler logHandler,
            IConsumerWorkerPool consumerWorkerPool)
        {
            this.configuration      = configuration;
            this.consumerManager    = consumerManager;
            this.logHandler         = logHandler;
            this.consumerWorkerPool = consumerWorkerPool;

            var kafkaConfig = configuration.GetKafkaConfig();

            this.consumerBuilder = new ConsumerBuilder <byte[], byte[]>(kafkaConfig);

            this.consumerBuilder.SetPartitionsAssignedHandler((consumer, partitions) => this.OnPartitionAssigned(consumer, partitions));
            this.consumerBuilder.SetPartitionsRevokedHandler((consumer, partitions) => this.OnPartitionRevoked(partitions));
        }
Beispiel #7
0
        public KafkaConsumer(
            ConsumerConfiguration configuration,
            IConsumerManager consumerManager,
            ILogHandler logHandler,
            IConsumerWorkerPool consumerWorkerPool,
            IDependencyResolver dependencyResolver,
            CancellationToken busStopCancellationToken)
        {
            this.Configuration            = configuration;
            this.consumerManager          = consumerManager;
            this.logHandler               = logHandler;
            this.consumerWorkerPool       = consumerWorkerPool;
            this.dependencyResolver       = dependencyResolver;
            this.busStopCancellationToken = busStopCancellationToken;

            var kafkaConfig = configuration.GetKafkaConfig();

            this.consumerBuilder = new ConsumerBuilder <byte[], byte[]>(kafkaConfig);

            this.consumerBuilder
            .SetPartitionsAssignedHandler((consumer, partitions) => this.OnPartitionAssigned(partitions))
            .SetPartitionsRevokedHandler((consumer, partitions) => this.OnPartitionRevoked(partitions))
            .SetErrorHandler(
                (p, error) =>
            {
                if (error.IsFatal)
                {
                    this.logHandler.Error("Kafka Consumer Fatal Error", null, new { Error = error });
                }
                else
                {
                    this.logHandler.Warning("Kafka Consumer Error", new { Error = error });
                }
            })
            .SetStatisticsHandler(
                (consumer, statistics) =>
            {
                foreach (var handler in configuration.StatisticsHandlers)
                {
                    handler.Invoke(statistics);
                }
            });
        }
        public KafkaConsumer(
            ConsumerConfiguration configuration,
            IConsumerManager consumerManager,
            ILogHandler logHandler,
            IConsumerWorkerPool consumerWorkerPool,
            CancellationToken busStopCancellationToken)
        {
            this.configuration            = configuration;
            this.consumerManager          = consumerManager;
            this.logHandler               = logHandler;
            this.consumerWorkerPool       = consumerWorkerPool;
            this.busStopCancellationToken = busStopCancellationToken;

            var kafkaConfig = configuration.GetKafkaConfig();

            this.consumerBuilder = new ConsumerBuilder <byte[], byte[]>(kafkaConfig);

            this.consumerBuilder
            .SetPartitionsAssignedHandler((consumer, partitions) => this.OnPartitionAssigned(consumer, partitions))
            .SetPartitionsRevokedHandler((consumer, partitions) => this.OnPartitionRevoked(partitions))
            .SetErrorHandler((p, error) => this.logHandler.Error("Kafka Consumer Error", null, new { Error = error }));
        }