How to delete Kafka topic using Kafka REST Proxy?

7.7k views Asked by At

How to delete Kafka topic using Kafka REST Proxy? I tried the following command, but it returns the error message:

curl -X DELETE XXX.XX.XXX.XX:9092/topics/test_topic

If it's impossible, then how to update delete the messages and update the scheme of a topic?

5

There are 5 answers

0
Yuriy Tseretyan On BEST ANSWER

According to the documentation API Reference, you cannot delete topics via REST Proxy, and I agree with them because such a destructive operation should not be available via interface that is exposed to outside.

The topic deletion operation can be performed on the server where broker runs using command line utility. See How to Delete a topic in apache kafka

0
Hans Jespersen On

You can update the schema for a message when you publish it using the POST /topics/(string: topic_name) REST endpoint. If the schema for the new messages is not backward compatible with the older messages in the same topic you will have to configure your Schema Registry to allow publishing of incompatible messages, otherwise you will get an error.

See the "Example Avro request" here: http://docs.confluent.io/3.1.1/kafka-rest/docs/api.html#post--topics-(string-topic_name)

See how to configure Schema Registry for forward, backward, or no compatibility see the documentation here: http://docs.confluent.io/3.1.1/schema-registry/docs/api.html#compatibility

0
wang9ri On

I confirmed that it is supported from version 5.5.0 or higher, and the test result worked normally. (REST Proxy API v3)

https://docs.confluent.io/current/kafka-rest/api.html#topic

0
Enzo Terranova On

according to rest proxy documentation, in order to delete a topic the call is this:

curl -X DELETE <REST_PROXY_URL>/clusters/<CLUSTER_ID>/topics/<TOPIC_NAME>
0
Boris Ivanov On

It's pretty simple. When You delete your topic in control center and realise(Use Inspect feature to sniff browser trafic) that deleting of topic is nothing but DELETE request to broker.

curl -s -X DELETE "http://kafka_broker:9021/2.0/kafka/${clusterid}/topics/${topic}"