Example #1
0
        public IConsumer <byte[], byte[]> GetConsumer(ConsumerConfig config, IConsumerRebalanceListener rebalanceListener)
        {
            ConsumerBuilder <byte[], byte[]> builder = builderKafkaHandler.GetConsumerBuilder(config);

            if (rebalanceListener != null)
            {
                builder.SetPartitionsAssignedHandler((c, p) => rebalanceListener.PartitionsAssigned(c, p));
                builder.SetPartitionsRevokedHandler((c, p) => rebalanceListener.PartitionsRevoked(c, p));
                builder.SetLogHandler(loggerAdapter.LogConsume);
                builder.SetErrorHandler(loggerAdapter.ErrorConsume);
                if (exposeLibrdKafka)
                {
                    // TODO : test librdkafka statistics with IntegrationTest (WIP see #82)
                    var consumerStatisticsHandler = new ConsumerStatisticsHandler(
                        config.ClientId,
                        streamConfig.ApplicationId,
                        (config as StreamizConsumerConfig)?.ThreadId);
                    consumerStatisticsHandler.Register(MetricsRegistry);
                    builder.SetStatisticsHandler((c, stat) =>
                    {
                        var statistics = JsonConvert.DeserializeObject <Statistics>(stat);
                        consumerStatisticsHandler.Publish(statistics);
                    });
                }
            }

            return(builder.Build());
        }
Example #2
0
 public void PartitionsAssigned(IConsumer <byte[], byte[]> consumer, List <TopicPartition> partitions)
 {
     if (partitions != null)
     {
         this.consumer.PartitionsAssigned(partitions);
     }
     wrapped?.PartitionsAssigned(consumer, partitions ?? new ());
 }
Example #3
0
        public IConsumer <byte[], byte[]> GetConsumer(ConsumerConfig config, IConsumerRebalanceListener rebalanceListener)
        {
            ConsumerBuilder <byte[], byte[]> builder = new ConsumerBuilder <byte[], byte[]>(config);

            if (rebalanceListener != null)
            {
                builder.SetPartitionsAssignedHandler((c, p) => rebalanceListener.PartitionsAssigned(c, p));
                builder.SetPartitionsRevokedHandler((c, p) => rebalanceListener.PartitionsRevoked(c, p));
                builder.SetLogHandler(loggerAdapter.LogConsume);
                builder.SetErrorHandler(loggerAdapter.ErrorConsume);
            }
            return(builder.Build());
        }
 public void PartitionsAssigned(IConsumer <byte[], byte[]> consumer, List <TopicPartition> partitions)
 {
     this.consumer.PartitionsAssigned(partitions);
     wrapped?.PartitionsAssigned(consumer, partitions);
 }