Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create kafka connector with the name which is not already in use

When I am trying to create a kafka connector with the name which is already in use through rest call, I got a error saying,

{"error_code":409,"message":"Connector Test already exists"}

I want to bypass this error , for example while creating kafka Topic we have something like below,

./kafka-topics **--if-not-exists**  --create --zookeeper localhost:2181 --replication-factor  1 --partitions 1  --topic test

Do we have something like --if-not-exists while creating kafka connectors?

like image 730
Sitharthan Anbazhakan Avatar asked Oct 28 '25 05:10

Sitharthan Anbazhakan


1 Answers

The way I like to do it us to use the PUT method to the config endpoint, like this:

curl -i -X PUT -H "Accept:application/json" -H  "Content-Type:application/json" \
http://localhost:8083/connectors/my-connector-name/config -d "@my-connector-config.json"

The behavior is to create in case it doesn't exist and update otherwise, more in the documentation here: https://docs.confluent.io/current/connect/references/restapi.html#put--connectors-(string-name)-config

Note that your json payload doesn't need to contain name and config, but only the config contents as in the docs example.

like image 75
Renato Mefi Avatar answered Oct 31 '25 00:10

Renato Mefi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!