Browse documentation

Kafka Producer: Sending Messages to a Topic

Send one record or generate repeatable test messages from the same Console tab where you inspect a Kafka topic.

What is a Kafka producer?

A Kafka producer publishes records to Kafka topics. It serializes each key and value, chooses a partition, and uses producer acks to control when a send is considered complete.

Apache Kafka includes kafka-console-producer for sending records from a terminal. Kafma keeps the same workflow next to the messages you are inspecting.

Kafma puts the Kafka producer and consumer in the same Console tab. Expand the producer to send test records, collapse it to focus on incoming messages, or leave a loop running while you inspect another tab or page in the same cluster. This keeps producing, consuming, and debugging in one workflow.

Send a Kafka message with a key and headers

Expand the producer and choose an encoding for the KEY and VALUE. Each side supports String, JSON, Bytes, UUID, Boolean, numeric types, and Null.

Enter the payload, add any key-value headers, then select Produce. Use Live to see the new record arrive in the stream above. New records do not appear automatically in a snapshot; refresh it after sending.

Null and an empty value are different in Kafka. Choose the Null encoding when you intend to send a tombstone rather than an empty payload.

Sending a Kafka message with a key and JSON value in Kafma’s producer

Produce Avro and Protobuf Kafka messages

The kafka-avro-console-producer and kafka-protobuf-console-producer commands send schema-encoded records from a terminal. In Kafma, a topic with matching Schema Registry subjects binds its key and value automatically.

Enter the message as JSON. Kafma validates it against the selected Avro, Protobuf, or JSON Schema, then serializes it with the schema ID consumers need to decode it. You can choose another subject manually, select a schema version, and select the Protobuf message type when a schema defines more than one.

Selecting a schema version for an Avro Kafka message in Kafma’s producer

Select Generate to create a sample from the active schema. To validate a payload without sending it, use Schema Lab.

Choose a partition and producer acks

Leave Partition on Auto to let the partitioner route the message, using its key when present. Select a specific partition when you need to reproduce partition-specific behavior.

Acks controls when the send is considered complete:

  • All waits for all in-sync replicas and is the default.
  • Leader waits only for the partition leader.
  • None does not wait for a broker acknowledgment, so no reliable offset is returned.

Generate Kafka test messages on a loop

Switch to Loop, set the interval, and select Run Loop. By default, every tick resends the current key, value, and headers. Enable auto-regeneration for KEY or VALUE independently when each message should be different.

With auto-regeneration enabled, a schema-bound field generates a schema-compatible value on each tick; an unbound field generates a random value for its selected encoding. The producer shows the sent count while the loop is running.

A running loop continues when you switch Console tabs or open another page for the same cluster. Return to the tab to check the sent count or stop it. Closing the tab or disconnecting the cluster stops the loop.

Kafma producing schema-generated Kafka messages every second while Live shows them arriving

Loop is for generating repeatable test messages, not throughput benchmarking. Stop it when the test is complete.

Next steps