Reference · Tools

Kafka

Produce messages to Apache Kafka topics with optional binary data, schema registry encoding, custom headers, keys, and GZIP compression.

Action (binary) Development v1 Binary data

The Kafka node publishes messages to Apache Kafka topics, supporting binary payloads, schema registry encoding, custom headers and message keys, and GZIP compression. A typical build is emitting a domain event onto a topic whenever a record changes, so downstream consumers pick it up without polling.

Node type
Action (binary)
Parameters
14
Outputs
Output, Error
Credentials
Kafka

Kafka

Produce messages to Apache Kafka topics

Overview

The Kafka tool produces messages to Apache Kafka topics using the kafkajs client library. It supports sending item JSON as message value, custom string messages, or binary data from upstream items. Features include: Confluent Schema Registry encoding, message keys, custom headers (UI or JSON), GZIP compression, and ack configuration. Messages are batched per topic and sent via producer.sendBatch() for efficiency. Authentication supports SASL (plain, scram-sha-256, scram-sha-512) with optional SSL.

Category: Development
Tool Name: kafka
Version: 1

Appearance: Icon: si-apachekafka | Color: #231F20

Node Type

Action (Binary) — handles file/binary data operations

Input / Output

DirectionPort(s)
InputInput
OutputOutput, Error

Credentials

This tool requires Kafka credentials. See the Credentials Guide for setup instructions.

Parameters

ParameterTypeRequiredDefaultDescription
TopicstringYesName of the Kafka topic to publish to.
Send Input DatabooleanNotrueWhether to send the incoming item JSON as the Kafka message value.
MessagestringNoCustom message string to send (when Send Input Data is false). (shown when Send Input Data is false)
Use Binary DatabooleanNofalseWhether to read binary data from the item and send it as the message value. (shown when Send Input Data is false)
Binary PropertystringNodataName of the binary property to read the message value from. Names are case-sensitive — see the upstream node’s Binary Data panel for the exact names to use. (shown when Send Input Data is false and Use Binary Data is true)
Use Schema RegistrybooleanNofalseWhether to encode messages via Confluent Schema Registry.
Schema Registry URLstringYesURL of the Confluent Schema Registry. (shown when Use Schema Registry is true)
Event NamestringYesNamespace and name of the schema in the Schema Registry (namespace.name). (shown when Use Schema Registry is true)
Use KeybooleanNofalseWhether to include a message key.
KeystringYesThe message key. (shown when Use Key is true)
JSON ParametersbooleanNofalseWhether to provide headers as a JSON string.
HeadersfixedCollectionNo{}Message headers as key-value pairs. (shown when JSON Parameters is false)
— KeystringNoThe header name.
— ValuestringNoThe header value.
Headers (JSON)jsonNoHeader parameters as a JSON object (flat key-value). (shown when JSON Parameters is true)
OptionscollectionNo{}Producer options.
— AcksoptionsNoallAcknowledgement level. “all” waits for all in-sync replicas (safest, required with idempotent producer); “leader” only waits for the partition leader; “none” does not wait.
Options: all (durable, wait for ISR), leader (wait for leader only), none (fire-and-forget)
— CompressionbooleanNofalseWhether to use GZIP compression for messages.
— TimeoutnumberNo30000Time to await a response from the broker in milliseconds (1000-300000).

This node has no Max Concurrency parameter: sends are grouped by topic and dispatched as batches rather than item by item.

Output Data

One output item per input item — the node never fans out. The send result is merged onto the input item JSON: the fields already on the item pass through, and the node adds two of its own. Binary data is forwarded unchanged.

  • _kafkaTopic — the topic this item was published to.
  • _kafkaResponse — an array describing the broker’s acknowledgement of the batch this item belonged to. Each entry covers one topic-partition and carries topicName, partition, errorCode, baseOffset, logAppendTime and logStartOffset. When the broker returns no per-partition detail, the array is [{ "success": true }] instead.
{
  "_kafkaTopic": "user-events",
  "_kafkaResponse": [
    {
      "topicName": "user-events",
      "partition": 0,
      "errorCode": 0,
      "baseOffset": "1042",
      "logAppendTime": "-1",
      "logStartOffset": "0"
    }
  ]
}

Because items are sent in batches, every item in the same batch receives the same _kafkaResponse array — it describes the batch, not that one message. Reference it downstream by expression, e.g. {{ $json._kafkaTopic }}.

Usage Examples

  • Send JSON data to a Kafka topic
  • Publish binary file content to Kafka
  • Produce keyed messages with GZIP compression
  • Send messages with custom headers
  • Encode messages with Confluent Schema Registry

Example Configuration

Publish each incoming item as a JSON message:

{
  "type": "kafka",
  "parameters": {
    "topic": "user-events",
    "sendInputData": true,
    "options": {
      "acks": "all",
      "timeout": 30000
    }
  }
}

Send a fixed message with a partition key and GZIP compression:

{
  "type": "kafka",
  "parameters": {
    "topic": "notifications",
    "sendInputData": false,
    "message": "System maintenance scheduled",
    "useKey": true,
    "key": "system-alert",
    "options": {
      "acks": "leader",
      "compression": true,
      "timeout": 15000
    }
  }
}

Publish a file from an upstream node as the message value:

{
  "type": "kafka",
  "parameters": {
    "topic": "file-uploads",
    "sendInputData": false,
    "useBinaryData": true,
    "binaryPropertyName": "data",
    "options": {
      "compression": true,
      "timeout": 45000
    }
  }
}

Encode messages with the Confluent Schema Registry and attach headers:

{
  "type": "kafka",
  "parameters": {
    "topic": "customer-data",
    "sendInputData": true,
    "useSchemaRegistry": true,
    "schemaRegistryUrl": "https://schema-registry.example.com:8081",
    "eventName": "customer.profile",
    "jsonParameters": true,
    "headerParametersJson": "{\"service\": \"api-gateway\", \"version\": \"1.2.3\"}",
    "options": {
      "acks": "all",
      "compression": true
    }
  }
}

Attach headers as key-value pairs instead of JSON:

{
  "type": "kafka",
  "parameters": {
    "topic": "audit-logs",
    "sendInputData": true,
    "jsonParameters": false,
    "headersUi": {
      "headerValues": [
        { "key": "event-type", "value": "user-login" },
        { "key": "correlation-id", "value": "req-12345" }
      ]
    },
    "options": {
      "timeout": 20000
    }
  }
}

Error Handling

ModeBehavior
stopHalts workflow on first error
continueSkips failed items, passes successful ones through
errorPortRoutes failed items to Error output port

Tips

Produce messages to Kafka topics with optional binary payloads, schema registry encoding, custom headers, and GZIP compression.

Frequently asked questions

Can I control which partition a message lands on?

Set a message key. Kafka partitions by key, so keying by an entity ID keeps that entity's events in order on the same partition.

Does it support schema registry?

Yes — schema registry encoding is supported, so messages can be published in the encoded form consumers expect rather than as raw JSON.

Can it send binary payloads?

Yes. Binary data from an upstream node can be produced as the message body, alongside the JSON path for ordinary structured events.

How do I reduce bandwidth on large messages?

Turn on GZIP compression, which is worth it for large or highly repetitive payloads.

Build with the Kafka node

Drop it into a workflow, wire it to an agent, or call it on a schedule. You'll need Kafka credentials first.

Open BusyBot

Last updated . Spotted something wrong? Tell us.