capabilities.work

Provision a Topic and Produce a Record

A 4-step recipe with Apache Kafka. We can help you get access.

Recipe · 4 steps

Provision a Topic and Produce a Record

Create a Kafka topic and verify it by producing a record to it.

  1. List the clusters behind the REST Proxy and take the first cluster id, so the rest of the flow does not depend on a hardcoded cluster identifier.
  2. Create the topic with an explicit partition count, replication factor, and retention policy rather than relying on broker defaults or on auto-topic creation, which produces single-partition unreplicated topics.
  3. Read the topic back from the broker to confirm the partitioning and replication that was actually applied, and that the topic is not internal.
  4. Produce a first record as a JSON key and value. A zero error_code in the response, together with the assigned partition and offset, proves the topic is writable.
What you'll need to have ready
  • topicName: The name of the topic to create.
  • partitionsCount: The number of partitions, which sets the ceiling on consumer parallelism for this topic and cannot easily be reduced later.
  • replicationFactor: The replication factor. Production topics should use at least 3 so the topic survives a broker loss.
  • retentionMs: Retention period in milliseconds, as a string config value.
  • recordKey: The partitioning key for the first record. Records sharing a key land on the same partition and keep their relative order.
  • recordValue: The JSON value of the first record to produce.
For your developer

Arazzo workflow apache-kafka:provision-topic-and-produce, 4 operations: listClusters → createTopic → getTopic → produceRecords. Specs on APIs.io.