I am using confluent http sink connector to read message from kafka topic and send it to an endpoint. Below is the http sink connector,
{
"name": "HttpSink",
"config": {
"topics": "http-messages",
"tasks.max": "1",
"connector.class": "io.confluent.connect.http.HttpSinkConnector",
"value.converter": "org.apache.kafka.connect.storage.StringConverter",
"topics":"topic-name",
"request.method":"POST",
"behavior.on.null.values":"ignore",
"behavior.on.error":"log",
"confluent.topic.bootstrap.servers": "localhost:9092",
"confluent.topic.replication.factor": "1",
"reporter.bootstrap.servers": "localhost:9092",
"reporter.result.topic.name": "success-responses",
"reporter.result.topic.replication.factor": "1",
"reporter.error.topic.name":"error-responses",
"reporter.error.topic.replication.factor":"1",
"http.api.url": "",
"auth.type":"BASIC",
"connection.user":"",
"connection.password":""
}
}
The messages in the topic has following json format,
{
"endpoint url": "http://localhost:8080/api/messages",
"rest method":"",
"credentials": {"username":"username", "password":"password"},
"payload": {}
}
So using http sink connector, I need to retrieve the value of "endpoint url" and "credentials" from topic message and use the same as a value for "http.api.url", "connection.user" and "connection.password" key's in the same connector.
So final format should look like,
{
"name": "HttpSink",
"config": {
"topics": "http-messages",
"tasks.max": "1",
"connector.class": "io.confluent.connect.http.HttpSinkConnector",
"value.converter": "org.apache.kafka.connect.storage.StringConverter",
"topics":"topic",
"request.method":"POST",
"behavior.on.null.values":"ignore",
"behavior.on.error":"log",
"confluent.topic.bootstrap.servers": "localhost:9092",
"confluent.topic.replication.factor": "1",
"reporter.bootstrap.servers": "localhost:9092",
"reporter.result.topic.name": "success-responses",
"reporter.result.topic.replication.factor": "1",
"reporter.error.topic.name":"error-responses",
"reporter.error.topic.replication.factor":"1",
"http.api.url": "http://localhost:8080/api/messages",
"auth.type":"BASIC",
"connection.user":"username",
"connection.password":"password"
}
}
How to retrieve data from the topic message and use it in the same connector?