Transport Kafka

Harmovela Transport Binding: Kafka

> Status: draft. Part of the Harmovela 0.2 transport-kafka profile.

Purpose

Define how Harmovela runs over Apache Kafka, supporting topic-based publish/subscribe with partition-based ordering and offset-based replay.

Framing

Harmovela over Kafka uses JSON-encoded Harmovela events as Kafka message values:

Message Key

The Kafka record key is derived from one of the following Harmovela envelope fields, in priority order:

PriorityFieldPurpose
1task_idAll events for a task land in the same partition
2conversation_idAll events for a conversation are ordered
3session_idEvents for a session are ordered
4sourceEvents from the same producer are ordered
5(none)Round-robin across partitions

Message Headers

HeaderHarmovela FieldType
aep-typetypestring
aep-sourcesourcestring
aep-sessionsession_idstring
aep-conversationconversation_idstring
aep-tasktask_idstring
aep-correlationcorrelation_idstring
aep-causationcausation_idstring
aep-delivery-modedelivery.modestring

Headers enable consumers to filter and route without deserializing the message body.

Topic Mapping

Harmovela contextKafka topic patternExample
Topic tasks.task_01aep.topic.tasks.task_01aep.topic.tasks.task_01
Source agent:researcheraep.source.agent.researcheraep.source.agent.researcher
Type pattern task.*aep.type.task.*Matches all task subtopics
Sessionaep.sess.<session_id>aep.sess.sess_01
All eventsaep.eventsSingle-topic deployment

The default topic prefix is aep. Implementations should allow per-envelope topic routing or single-topic deployment with header-based filtering.

Delivery Modes

Harmovela Delivery ModeKafka Mechanism
best_effortFire-and-forget producer with acks=0
at_least_onceProducer with acks=1 or acks=all, consumer with manual commit after processing
replayableConsumer with auto.offset.reset=earliest, replay by seeking to offset

At-Least-Once

Replayable

Consumer Groups

Harmovela sessions map to Kafka consumer groups:

SessionConsumer Group
sess_01aep-sess_01
Multiple agents sharing a sessionSame group — events distributed across members
Independent sessionsSeparate groups — each receives full event stream

Partitioning And Ordering

Ordering is guaranteed within a partition, not across partitions:

For strict ordering, route all events through a single partition (num.partitions=1) or use a consistent key (e.g., session_id).

Session Lifecycle

Kafka StateSession State
Consumer connects and joins groupCREATED
Partition assignment receivedOPENED
First event consumedREADY
Consumer leaves group (graceful)CLOSED
Consumer session timeoutERROR

Implementation Notes

References