> For the complete documentation index, see [llms.txt](https://docs.fractalworks.io/joule/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fractalworks.io/joule/components/connectors/sinks/kafka.md). Agents can also search and read this documentation through its [MCP server](https://docs.fractalworks.io/joule/~gitbook/mcp).

# Kafka

Sends events to specified Kafka topics, enabling real-time data streams

## Overview

The Kafka Publisher Transport enables publishing of processed events to a specified Kafka topic. Events are serialised using either a default JSON serialiser (`StreamEventJsonSerializer`) or a custom transformer.

## Examples & DSL attributes

```yaml
kafka publisher:
  cluster address: KAFKA_BROKER:9092
  topic: customers
  partitionKeys:
    - customerId
```

### Serialiser example

```yaml
kafka publisher:
  cluster address: localhost:9092
  topic: customers
  partitionKeys:
    - customerId
  serializer:
    key serializer: org.apache.kafka.common.serialization.IntegerSerializer
    value serializer: com.fractalworks.streams.transport.kafka.serializers.json.StreamEventJsonSerializer
```

### OOTB serialisers

```
com.fractalworks.streams.transport.kafka.serializers.object.ObjectSerializer
com.fractalworks.streams.transport.kafka.serializers.json.StreamEventJsonSerializer
com.fractalworks.streams.transport.kafka.serializers.avro.AvroStreamEventSerializer
```

### Avro publishing with Schema Registry

Joule's `KafkaAvroSerializer` supports Confluent Schema Registry wire format. When `schema.registry.url` is set in the `properties` block the serialiser automatically registers the Avro schema on first publish and prepends the standard 5-byte header to every message.

```yaml
kafka publisher:
  cluster address: localhost:19092
  topic: market_data_eod
  partitionKeys:
    - symbol
  serializer:
    key serializer: org.apache.kafka.common.serialization.IntegerSerializer
    value serializer: com.fractalworks.streams.transport.kafka.serializers.avro.KafkaAvroSerializer
  properties:
    schema.registry.url: http://redpanda:8081
```

| Property              | Description                                                       |
| --------------------- | ----------------------------------------------------------------- |
| `schema.registry.url` | Base URL of the Schema Registry. Omit for raw Avro binary.        |
| `schema.subject`      | Override subject name. Default: `{topic}-value` or `{topic}-key`. |

### Default producer properties

```properties
acks=0
retries=1
linger.ms=5
buffer.memory=33554432
request.timeout.ms=60000
key.serializer=org.apache.kafka.common.serialization.IntegerSerializer
value.serializer=org.apache.kafka.common.serialization.StringSerializer
partitioner.class=com.fractalworks.streams.transport.kafka.KeyPartitioner
```
