Skip to main content

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-serializer dependency

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:

LibraryLanguageConfiguration
JacksonJava, Kotlin, ScalaJsonLib.Jackson
CirceScalaJsonLib.Circe
ZIO JSONScalaJsonLib.ZioJson

Use when:

  • Human-readable messages preferred
  • Debugging or development
  • Interoperability with non-JVM systems

Comparison​

FormatSizeSchema RegistryHuman ReadableSchema Evolution
Avro + ConfluentSmallRequiredNoAutomatic
Plain AvroSmallNoNoManual
JSONLargeNoYesManual