question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consuming from Invalid Topic and End of Valid Topic is Indistinguishable

See original GitHub issue

Description

Subscribing to a valid or invalid topic and calling var messageConsumed = Consumer.Consume(out kafkaMessage, pollInterval) the consumer just returns a null value making it unclear if the consumer is just reading from the end of a valid topic and there is no more messages or if the consumer is subscribed to an invalid topic.

Observed behavior is consuming from an invalid topic silently returns a null message.

Expected behavior for the case of an invalid topic was that it would be similar to what is displayed by producer: Trying to consume from an invalid topic would result in a Message being returned with invalid offset and error code such as code 3 for Unknown Topic or Partition, or at the very least and exception being thrown for consuming from invalid topic.

Shouldn’t there be a clear difference between consuming from the end of a valid topic and a topic that doesn’t exist so the implementation knows that it is in an error state?

As a side note it occurred to me to check for the OnError or OnConsumeError events while checking for any similar issues and neither of these events are being triggered in the invalid topic scenario.

How to reproduce

Just consuming from a none existent topic as follows:

try
{
    var config  = new Dictionary<string, object>
    {
        {"group.id", "ConsumerId"},
        {"enable.auto.commit", false},
        {"log.connection.close", false},
        {"socket.keepalive.enable", true},
        {"statistics.interval.ms", 60000},
        {"bootstrap.servers", localhost:9092},
    };
    var consumer= new Consumer(config);
    consumer.Subscribe("Some-Invalid-Topic-Name");
    var messageConsumed = false;
    while (!messageConsumed && kafkaMessage == null)
    {
        messageConsumed = consumer.Consume(out kafkaMessage, pollInterval);
    }
    Console.WriteLine("Never Escapes the While Loop.");
}
catch (exception e)
{
    Console.WriteLine("Never Catches a Exception.");
}

Currently using Kafka Server version 2.11-0.10.2.1 Server Configured to Auto Create Topics = false

Confluent Kafka Dotnet version 11.2

Passed Consumer Configuration:

  • group.id was set
  • enable.auto.commit = false
  • log.connection.close = false
  • socket.keepalive.enable = true
  • statistics.interval.ms = 60000
  • bootstrap.servers pointed to network cluster

Currently developing Windows 7 / 10 / Server 2012 operating systems we are moving towards .net core 2.0 and supporting Linux Centos/Ubuntu distros as well.

Checklist

Please provide the following information:

  • Confluent.Kafka nuget version:
  • Apache Kafka version:
  • Client configuration:
  • Operating system:
  • Provide logs (with “debug” : “…” as necessary in configuration)
  • Provide broker log excerpts
  • Critical issue

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
edenhillcommented, Nov 21, 2017

I agree, it should fire off an _UNKNOWN_TOPIC or …_PARTITION consumer error.

This issue should be moved to librdkafka.

0reactions
mhowlettcommented, Aug 14, 2018

closing, this is being tracked in https://github.com/edenhill/librdkafka/issues/1540

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kafka 3.5 Documentation
When a new event is published to a topic, it is actually appended to one of the topic's partitions. Events with the same...
Read more >
Fix Swagger Validator errors in Power Platform connectors
Your swagger has an invalid URL. This can be due to incorrectly copying the URL from somewhere. Response. Error, Issue, Solution ...
Read more >
SAT Practice Test #5 Answer Explanations
Choices A and D are incorrect because they provide singular verbs that don't agree in number with the plural subject “researchers.” Choice C...
Read more >
Publication 103, Sales for Resale - CDTFA
The date of the document (an otherwise valid resale certificate will not be considered invalid solely because it is undated). The signature of...
Read more >
Opinion Paper: “So what if ChatGPT wrote it? ...
Abstract. Transformative artificially intelligent tools, such as ChatGPT, designed to generate sophisticated text indistinguishable from that produced by a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found