Docs / Strand / connectors/kafka

Apache Kafka Connector

Produce messages to and consume messages from Apache Kafka topics in your Strand workflows.

Prerequisites

You need Kafka cluster connection details to use this connector. You can connect to a managed Kafka service or a cluster you run yourself.

Your brokers must be reachable from the internet. Strand runs in the cloud
and can only connect to publicly reachable addresses — not 10.x,
172.16–31.x, 192.168.x or 127.x.
A cluster on an internal network needs a public listener or a tunnel; see
Connectors.
Note that the advertised listener matters as much as the bootstrap address: a
broker that advertises a private hostname will fail after the initial connect.

Managed Kafka (Confluent Cloud, AWS MSK, Aiven, etc.)

  1. Sign in to your Kafka provider's dashboard
  2. Locate your cluster and find the connection details:

Required Permissions

If your Kafka cluster uses ACLs, the SASL user must have the following permissions:

Operation Required ACL Permissions
Produce WRITE on topic, DESCRIBE on topic
Consume READ on topic, READ on consumer group, DESCRIBE on topic
Tip: In Confluent Cloud, configure ACLs under Cluster settings > ACLs. For self-hosted clusters, use kafka-acls.sh. Scope permissions to specific topic and consumer group names.

Self-Hosted Kafka

  1. Note the Bootstrap Servers of your Kafka cluster (comma-separated list of host:port)
  2. Determine the security configuration:
Tip: Use a dedicated set of credentials for your Strand workflows. For managed services, create an API key scoped to only the topics your workflows need.

Connector Setup

Create a Kafka connector from the Connectors page.

Configuration Fields

Field Required Description
Name Yes Friendly name (e.g., "Production Kafka")
Bootstrap Servers Yes Comma-separated list of broker addresses (e.g., broker1:9092,broker2:9092)
Security Protocol No Connection security: PLAINTEXT, SSL, SASL_PLAINTEXT, or SASL_SSL (default: SASL_SSL)
SASL Mechanism No Authentication mechanism: PLAIN, SCRAM-SHA-256, or SCRAM-SHA-512 (required when using SASL)
SASL Username No SASL authentication username or API key (encrypted at rest)
SASL Password No SASL authentication password or API secret (encrypted at rest)
Timeout No Connection and operation timeout in seconds (default: 30)
Description No Optional description for reference

Operations

Produce

Publish a message to a Kafka topic.

Field Required Description
Topic Yes The Kafka topic to produce to (e.g., order-events)
Message Yes Message value (string or JSON)
Key No Message key for partitioning (messages with the same key go to the same partition)
Partition No Specific partition number to produce to (overrides key-based partitioning)
Headers (JSON) No JSON object of key-value pairs to include as message headers

Example: Produce an order event:

json

{
  "event_type": "order_placed",
  "order_id": "{{ payload.order_id }}",
  "customer_id": "{{ payload.customer_id }}",
  "items": {{ payload.items }},
  "total": {{ payload.total }},
  "timestamp": "{{ payload.timestamp }}"
}
json

{
  "source": "strand-workflow",
  "correlation-id": "{{ payload.trace_id }}"
}

Example: Produce a notification with a specific partition:

Consume

Consume messages from a Kafka topic. Returns a batch of messages up to the specified limit.

Field Required Description
Topic Yes The Kafka topic to consume from
Group ID Yes Consumer group ID (e.g., strand-workflow-consumers)
Timeout No Maximum time in seconds to wait for messages (default: 5)
Max Messages No Maximum number of messages to return (default: 10)

A consumer with no committed offset always starts from the earliest available message; this is fixed and not configurable per node.

Example: Consume from an events topic:

Output

Produce Output

json

{
  "success": true,
  "status": "sent",
  "data": {
    "topic": "order-events",
    "partition": 3,
    "offset": 1542,
    "key": "CUST-001",
    "timestamp": "2026-02-18T14:30:00Z"
  },
  "service": "kafka",
  "operation": "produce"
}

Key fields for subsequent nodes:

Consume Output

json

{
  "success": true,
  "status": "completed",
  "data": {
    "messages": [
      {
        "topic": "order-events",
        "partition": 3,
        "offset": 1540,
        "key": "CUST-001",
        "value": "{\"event_type\":\"order_placed\",\"order_id\":\"ORD-001\",\"total\":149.99}",
        "timestamp": "2026-02-18T14:28:00Z",
        "headers": {"source": "strand-workflow"}
      },
      {
        "topic": "order-events",
        "partition": 3,
        "offset": 1541,
        "key": "CUST-002",
        "value": "{\"event_type\":\"order_placed\",\"order_id\":\"ORD-002\",\"total\":89.50}",
        "timestamp": "2026-02-18T14:29:00Z",
        "headers": {"source": "strand-workflow"}
      }
    ],
    "count": 2,
    "group_id": "strand-order-processor"
  },
  "service": "kafka",
  "operation": "consume"
}

Key fields for subsequent nodes:

Errors

Error Meaning
Kafka bootstrap_servers is required Bootstrap servers not configured in connector.
Topic is required No topic specified for the operation.
Message is required No message provided for a Produce operation.
Group ID is required No consumer group ID specified for a Consume operation.
SASL username and password are required SASL authentication is configured but credentials are missing.
NoBrokersAvailable Could not connect to any bootstrap server. Check the address and network access.
TopicAuthorizationFailedError The credentials lack permission to access the specified topic.
UnknownTopicOrPartitionError The specified topic does not exist on the cluster.
SaslAuthenticationException SASL authentication failed. Check username, password, and mechanism.
GroupAuthorizationFailedError The credentials lack permission to use the specified consumer group.
MessageSizeTooLargeError The message exceeds the broker's maximum message size (default: 1 MB).
KafkaTimeoutError The operation timed out. Increase the timeout or check broker availability.

Example Workflow

  1. Create Connector with your Kafka bootstrap servers and SASL credentials
  2. Produce an event when a workflow triggers:
  1. Process the event in downstream workflow nodes
  2. Produce a completion event:

Limitations