POST to Gateway’s records API, without a Kafka client. Gateway produces each record as the caller, so the same authentication, ACLs, Virtual Cluster and Interceptors apply as for any other Kafka client connecting to Gateway.
Before you start
GATEWAY_FEATURE_FLAGS_RECORDS_APIset totrue.- Access to the records API listener, on port
8889by default. - A
SASL_PLAINTEXTlistener on Gateway. Gateway produces as the caller through this listener. - SASL/PLAIN credentials for the caller.
Produce a record
1
Get credentials
Use the Kafka credentials the client would use against Gateway. They depend on Gateway’s security mode, set by
GATEWAY_SECURITY_MODE:- In
KAFKA_MANAGEDmode, the backing Kafka cluster checks the credentials. Use a SASL/PLAIN user and password from that cluster. - In
GATEWAY_MANAGEDmode, Gateway checks the credentials. Create a local service account and generate a token for it:
2
Send the record
Produce a JSON value with a string key and an example header. Header values are base64-encoded, and
cmVzdA== is rest:3
Check the response
Gateway returns the topic, partition and offset the record was written to:
Produce several records in one request
Put several record objects one after the other in the body. Gateway returns one result per record, in the same order, and writes the records in that order:200, so check the errorCode of each result: 200 means the record was written, any other value means it failed, with the reason in message: