Subjects and Kafka Topics

The mapping between Kafkorama subjects and Kafka topics is automatic, following a simple convention. This eliminates the need to define mappings manually in configuration files.

A Kafkorama subject is a UTF-8 string that follows a syntax similar to Unix absolute paths. It begins with a forward slash (/), followed by one or more segments separated by slashes. Each segment is a sequence of characters where the slash character (/) is reserved and cannot be used. For example, the string /Stocks/NYSE/IBM is a valid subject, consisting of the segments Stocks, NYSE, and IBM.

Kafkorama maps subjects to Kafka topics using the following convention:

  • The first segment of the subject becomes the Kafka topic name.
  • The remaining segments are concatenated to form the Kafka message key.

This means the first segment must follow Kafka's topic naming rules: it must be non-empty and may contain only the following characters: [a-zA-Z0-9._-] (up to 249 characters). The remaining segments (used as key) can contain any UTF-8 characters, as Kafka imposes no restrictions on keys. If a subject consists of only one segment, the message key is set to null.

Example Mappings

Kafkorama Subject Kafka Topic Kafka Key
/vehicles/1 vehicles 1
/vehicles/1/speed vehicles 1/speed
/vehicles vehicles null
© 2025 MigratoryData. All rights reserved.

Table of Contents