Producer API is used to send one or more messages to the same or multiple Kafka topics.
There are three variants of the Producer API:
GET /produce/$TOPIC/$MESSAGE?key=$KEY
:
Sends a single message ($MESSAGE
) to a topic ($TOPIC
) using HTTP GET.
Optionally message key can be appended with a query parameter?key=$KEY
.
Without message key:
With a message key:
Response:
A single metadata response is returned as JSON. Its structure is:
[GET | POST] /produce/$TOPIC
:
Produces one or more messages to a single topic ($TOPIC
). Messages are sent
using request body as JSON. Structure of the message JSON is:
Only value
field is required. partition
, timestamp
, key
and headers
fields are optional. When left blank, partition
and timestamp
fields will
be assigned by Kafka brokers. It’s valid to send a single message or array of
messages as JSON.
Response:
A metadata array response is returned as JSON. Its structure is same as above. Each metadata in the response array belongs the message with the same order in the request.
[GET | POST] /produce
:
Produces one or more messages to a single or multiple topics. Messages are
sent using request body as JSON. Structure of the message JSON is the same as
the above, there’s only an additional topic
field:
Only topic
and value
fields are required. partition
, timestamp
, key
and headers
fields are optional. When left blank, partition
and
timestamp
fields will be assigned by Kafka brokers. It’s valid to send a
single message or array of messages as JSON.
Response:
A metadata array response is returned as JSON. Its structure is same as above. Each metadata in the response array belongs the message with the same order in the request.
Producer API works with acks=all
producer
configuration,
which means the topic partition’s leader will wait for the all in-sync
replicas to acknowledge the produced messages.
Producer API is used to send one or more messages to the same or multiple Kafka topics.
There are three variants of the Producer API:
GET /produce/$TOPIC/$MESSAGE?key=$KEY
:
Sends a single message ($MESSAGE
) to a topic ($TOPIC
) using HTTP GET.
Optionally message key can be appended with a query parameter?key=$KEY
.
Without message key:
With a message key:
Response:
A single metadata response is returned as JSON. Its structure is:
[GET | POST] /produce/$TOPIC
:
Produces one or more messages to a single topic ($TOPIC
). Messages are sent
using request body as JSON. Structure of the message JSON is:
Only value
field is required. partition
, timestamp
, key
and headers
fields are optional. When left blank, partition
and timestamp
fields will
be assigned by Kafka brokers. It’s valid to send a single message or array of
messages as JSON.
Response:
A metadata array response is returned as JSON. Its structure is same as above. Each metadata in the response array belongs the message with the same order in the request.
[GET | POST] /produce
:
Produces one or more messages to a single or multiple topics. Messages are
sent using request body as JSON. Structure of the message JSON is the same as
the above, there’s only an additional topic
field:
Only topic
and value
fields are required. partition
, timestamp
, key
and headers
fields are optional. When left blank, partition
and
timestamp
fields will be assigned by Kafka brokers. It’s valid to send a
single message or array of messages as JSON.
Response:
A metadata array response is returned as JSON. Its structure is same as above. Each metadata in the response array belongs the message with the same order in the request.
Producer API works with acks=all
producer
configuration,
which means the topic partition’s leader will wait for the all in-sync
replicas to acknowledge the produced messages.