public KafkaConsumer(KafkaConsumerOptions options)
        {
            MessageReceived = new MessageReceivedHandler <TMessage>(onMessageReceived);

            _options = options;

            var conf = new ConsumerConfig
            {
                GroupId          = _options.GroupId,
                BootstrapServers = _options.BootstrapServers,
                // Note: The AutoOffsetReset property determines the start offset in the event
                // there are not yet any committed offsets for the consumer group for the
                // topic/partitions of interest. By default, offsets are committed
                // automatically, so in this example, consumption will only start from the
                // earliest message in the topic 'my-topic' the first time you run the program.
                AutoOffsetReset = (AutoOffsetReset)_options.AutoOffsetReset
            };

            _consumer         = new ConsumerBuilder <Ignore, string>(conf).Build();
            cancellationToken = new CancellationTokenSource();
            _consumer.Subscribe(_options.Topic);
        }
 public KafkaConsumer <TMessage> CreateConsumer <TMessage>(KafkaConsumerOptions options) where TMessage : KafkaMessage
 {
     return(new KafkaConsumer <TMessage>(options));
 }