Create a new topic with the admin API using librdkafka++ #4282
Unanswered
SoulfreezerXP
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using the librdkafka++ (C++17) in a larger application, which successfully runs a producer instance.
This is instantiated as follows:
RdKafka::Producer * _producer = RdKafka::Producer::create( conf, errstr );
I am now faced with the difficult task that the application (preferably at startup) should create its
topic (replication factor 3 and partition count 5) itself.
Currently, the only way I can solve the task is to first manually issue the following curl call beforehand:
curl -X POST -H "Content-Type: application/json" --data '{"topic_name": "my__events"}' http://kafka01:8082/v3/clusters/KGRsTDIGdERGKgkggkds/topics
But now I have read that this should also work via the so called "Admin-API", but not via librdkafka++,
only via the C-API. This would not be a problem, however I can't find a simple/minimal example of
how to make this happen!
If I understood it right, something like this can be solved with
rd_kafka_AdminOptions_new(rk, ..?..)
, but I don't have rk (rd_kafka_t*) at hand, only my RdKafka::Producer*. Also there isrd_kafka_CreateTopics(...)
, but there I need alsord_kafka_t* and also some type of queue?
Can I get plz mimimal_ code snippet on how to create a simple topic (factor3, partitions 5) non-blocking (no feedback needed).
via the admin API?
Beta Was this translation helpful? Give feedback.
All reactions