Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine API version of Kafka?

I am using kafka-python for accessing Kafka. I try to create a Kafka Producer:

kafka_producer = KafkaProducer(bootstrap_servers=['kafka:9092'])

but this fails with exception kafka.errors.NoBrokersAvailable: NoBrokersAvailable.

I've found out I need to add api_version parameter to the KafkaProducer:

kafka_producer = KafkaProducer(bootstrap_servers=['kafka:9092'],
                               api_version=(0, 10, 1))

This command works.

The question is: how to determine value of api_version?

kafka-broker-api-versions.sh --bootstrap-server localhost:9092 gives me something, but I am not sure if there's a number I can use. I tried random values like api_version=(20, 2, 1) and it also worked.

like image 755
Michal Špondr Avatar asked Jul 17 '19 13:07

Michal Špondr


People also ask

How do I find Kafka version?

Determine Kafka version by checking runtime class. Determine Kafka version by checking used library. It is Kafka 2.8. 0 using Scala 2.13.

What are the APIs in Kafka?

Kafka APIsThe Admin API to manage and inspect topics, brokers, and other Kafka objects. The Producer API to publish (write) a stream of events to one or more Kafka topics. The Consumer API to subscribe to (read) one or more topics and to process the stream of events produced to them.

What does ACKS =- 1 mean in Kafka?

With acks = -1, the producer waits for the ack. This ack is sent by the broker as above but only after having the messages replicated to all the replica followers on the other brokers.

What is Api_version for in Kafka?

If you set an api_version directly, you are telling the kafka-python client to always send api requests using that version. This should work for all broker versions equal to or newer than the client version you have chosen.


1 Answers

This was solved in the discussion in the comments already:

Ideally, it's the version of Kafka you've installed, or the lowest version you're targeting. 0.10.2 is a safe default

That's that point at which any version of newer clients should work - cwiki.apache.org/confluence/display/KAFKA/Compatibility+Matrix

like image 157
Dennis Jaheruddin Avatar answered Sep 19 '22 08:09

Dennis Jaheruddin