scalacode
scalacode

Reputation: 1106

install a connector to kafka connect using rest API

I want to add a connector to my local Kafka cluster using apache Kafka Connect Rest API . Do you know any example to do this, please. Thanks

Upvotes: 1

Views: 1308

Answers (1)

Giorgos Myrianthous
Giorgos Myrianthous

Reputation: 39820

Confluent's documentation includes a clear example on how to add a Connector through Kafka REST API:

POST /connectors

Create a new connector, returning the current connector info if successful.

Return 409 (Conflict) if rebalance is in process.

Example Request:

POST /connectors HTTP/1.1
Host: connect.example.com
Content-Type: application/json
Accept: application/json

{
    "name": "hdfs-sink-connector",
    "config": {
        "connector.class": "io.confluent.connect.hdfs.HdfsSinkConnector",
        "tasks.max": "10",
        "topics": "test-topic",
        "hdfs.url": "hdfs://fakehost:9000",
        "hadoop.conf.dir": "/opt/hadoop/conf",
        "hadoop.home": "/opt/hadoop",
        "flush.size": "100",
        "rotate.interval.ms": "1000"
    }
}

Example Response:

HTTP/1.1 201 Created
Content-Type: application/json

{
    "name": "hdfs-sink-connector",
    "config": {
        "connector.class": "io.confluent.connect.hdfs.HdfsSinkConnector",
        "tasks.max": "10",
        "topics": "test-topic",
        "hdfs.url": "hdfs://fakehost:9000",
        "hadoop.conf.dir": "/opt/hadoop/conf",
        "hadoop.home": "/opt/hadoop",
        "flush.size": "100",
        "rotate.interval.ms": "1000"
    },
    "tasks": [
        { "connector": "hdfs-sink-connector", "task": 1 },
        { "connector": "hdfs-sink-connector", "task": 2 },
        { "connector": "hdfs-sink-connector", "task": 3 }
    ]
}
GET /

Upvotes: 1

Related Questions