Class KafkaTransport

All Implemented Interfaces:
Closeable, AutoCloseable

public final class KafkaTransport extends PollingTransport

Messaging over Apache Kafka, with no client library.

cn1.messaging.url=kafka://broker1:9092,broker2:9092

A destination is a topic, created by the broker on first use when it allows that (auto.create.topics.enable, its default). A send is one record, acknowledged by every in-sync replica (acks=all); a keyed one goes to the partition Kafka's own partitioner would choose, so records of one key stay in order, and an unkeyed one goes round the partitions.

A listener's group is a Kafka consumer group: each group sees every record, and within one the partitions are shared out among its members by range, as the Java client's default does. Records of one partition are handled one at a time, in order, and the group's offset moves past a record only after its handler returned; concurrency beyond the number of partitions a member holds therefore waits. Offsets are committed within a second of a handler finishing, and before the member gives its partitions up.

A record whose handler failed goes to <topic>.retry.<group>, which the group also consumes: a partition of it waits until its first record is due, so retries never hold up the topic itself -- what Spring Kafka calls a non-blocking retry. One that fails every attempt goes to <topic>.dlq.

A new group starts at the earliest offset, so nothing sent before a listener first started is skipped; cn1.messaging.kafka.auto-offset-reset (or Spring Boot's spring.kafka.consumer.auto-offset-reset) set to latest starts at the end instead. Records compressed with gzip can be read; snappy, lz4 and zstd cannot, and a topic holding them fails its consumer. Transactions and SASL are not supported.