Wire Formats
Typr Events supports multiple serialization formats for Kafka messages.
Avro + Confluent Schema Registryβ
The default format. Uses binary Avro with Confluent Schema Registry for schema evolution.
val options = AvroOptions.default(...).copy(
wireFormat = AvroWireFormat.ConfluentAvro
)
Requirements:
- Confluent Schema Registry running
io.confluent:kafka-avro-serializerdependency
Kafka properties:
props.put("schema.registry.url", "http://localhost:8081");
Plain Avroβ
Binary Avro without Schema Registry. Schema is embedded or agreed upon out-of-band.
val options = AvroOptions.default(...).copy(
wireFormat = AvroWireFormat.PlainAvro
)
Use when:
- No Schema Registry available
- Schema evolution handled manually
- Testing without infrastructure
JSONβ
JSON serialization using your preferred JSON library.
val options = AvroOptions.default(...).copy(
wireFormat = AvroWireFormat.JsonEncoded(JsonLib.Jackson)
)
Supported JSON libraries:
| Library | Language | Configuration |
|---|---|---|
| Jackson | Java, Kotlin, Scala | JsonLib.Jackson |
| Circe | Scala | JsonLib.Circe |
| ZIO JSON | Scala | JsonLib.ZioJson |
Use when:
- Human-readable messages preferred
- Debugging or development
- Interoperability with non-JVM systems
Comparisonβ
| Format | Size | Schema Registry | Human Readable | Schema Evolution |
|---|---|---|---|---|
| Avro + Confluent | Small | Required | No | Automatic |
| Plain Avro | Small | No | No | Manual |
| JSON | Large | No | Yes | Manual |