confluent-kafka-python icon indicating copy to clipboard operation
confluent-kafka-python copied to clipboard

About creating consumers

Open cxin-william opened this issue 4 years ago • 8 comments

c = Consumer({ 'bootstrap.servers': servers, 'group.id': groupid, 'auto.offset.reset': offsettype, # 'auto.offset.reset': 'latest', }) c.subscribe([topic]) When I created the consumer, I thought it would be obvious if there was no data because KAFKA was not connected

Checklist

Please provide the following information:

  • [ ] confluent-kafka-python and librdkafka version (confluent_kafka.version() and confluent_kafka.libversion()):
  • [ ] Apache Kafka broker version:
  • [ ] Client configuration: {...}
  • [ ] Operating system:
  • [ ] Provide client logs (with 'debug': '..' as necessary)
  • [ ] Provide broker log excerpts
  • [ ] Critical issue

cxin-william avatar Nov 08 '21 03:11 cxin-william

Could you please clarify your questions and fill the above checklist?

jliunyu avatar Feb 08 '22 07:02 jliunyu

What I mean by this is that kafka should be reported when there is a problem with the connection, otherwise the data is empty and it is easy to confuse whether the data is empty or not connected

cxin-william avatar Feb 08 '22 08:02 cxin-william

Did you meet some special case that connecting failed but without reporting any error? I just tried with your config and saw this error:

%3|1644308485.667|FAIL|rdkafka#consumer-1| [thrd:127.0.0.1:9092/bootstrap]: 127.0.0.1:9092/bootstrap: Connect to ipv4#127.0.0.1:9092 failed: Connection refused (after 0ms in state CONNECT)
jliu@C02DM32YMD6T confluent-kafka-python % 

jliunyu avatar Feb 08 '22 08:02 jliunyu

For example, fill in the wrong topic

cxin-william avatar Feb 09 '22 01:02 cxin-william

I tried with the go client, found that if the topic is not exist, the error is Error: Broker: Unknown topic or partition: Subscribed topic not available: topic12: Broker: Unknown topic or partition for consumer rdkafka#consumer-1

But for python clients, if the topic the wrong, we are not able to capture it, even error_cb not works.

We are looking into it.

jliunyu avatar Mar 23 '22 00:03 jliunyu

You should see the same thing with the Python client by inspecting msg.error() of polled messages.

edenhill avatar Mar 23 '22 07:03 edenhill

Also see https://github.com/edenhill/librdkafka/wiki/FAQ#is-kafka-up

edenhill avatar Mar 23 '22 07:03 edenhill