You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/utilities/kafka.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -258,15 +258,15 @@ Each Kafka record contains important metadata that you can access alongside the
258
258
259
259
### Using an offline Avro schema with a schema-registry wire-format prefix
260
260
261
-
When Confluent serializes messages with its schema-registry-aware Avro serializer (i.e. `KafkaAvroSerializer`), each payload carries a short wire-format prefix in front of the Avro body.
262
-
Said prefix is 5 bytes long, consisting of 1B magic byte (0x00) and 4B big-endian schema ID.
261
+
When Confluent serializes messages with its schema-registry-aware Avro serializer (for example, `KafkaAvroSerializer`), each payload carries a wire-format header before the Avro body.
262
+
The header is 5 bytes long: 1-byte magic byte (`0x00`) followed by a 4-byte big-endian schema ID.
263
263
264
-
When the ESM Schema Registry integration is enabled, Lambda strips those bytes automatically and populates `value_schema_metadata.schemaId`. But when an **offline Avro schema**is used (checked into your Lambda) and do **not** use the ESM Schema Registry integration, those prefix bytes reach the function and would otherwise corrupt Avro deserialization.
264
+
When the ESM Schema Registry integration is enabled, Lambda strips those bytes and populates the record's schema metadata. When you use an **offline Avro schema**without the ESM Schema Registry integration, the header reaches the function and prevents plain Avro deserialization.
265
265
266
-
By setting the `value_schema_id_wire_format` argument on `SchemaConfig` to `"CONFLUENT"`, Powertools with strip the leading 5 bytes of the payload before running the Avro decoder.
266
+
Set `value_schema_wire_format` or `key_schema_wire_format`on `SchemaConfig` to `"CONFLUENT"`. Powertools validates the magic byte and strips the 5-byte header before running the Avro decoder.
267
267
268
268
???+ info "When do I need this?"
269
-
Only when you are supplying the Avro schema yourself **and** the producer is Confluent. If the ESM Schema Registry integration is on, leave this parameter at its default (`None`).
269
+
Use this option when you supply the Avro schema and the producer uses the Confluent wire format. If ESM Schema Registry integration has already removed the header, leave the option as `None`.
270
270
271
271
=== "Offline Avro schema with a Confluent prefix"
272
272
@@ -280,20 +280,20 @@ By setting the `value_schema_id_wire_format` argument on `SchemaConfig` to `"CON
# record.value is the fully-deserialized Avro payload
291
-
# with the 5-byte wire-format **prefix** stripped.
290
+
# record.value is the deserialized Avro payload
291
+
# with the validated 5-byte wire-format header removed.
292
292
...
293
293
```
294
294
295
295
???+ warning "Scope"
296
-
`value_schema_id_wire_format` only affects the **Avro**deserializer, just for value payloads. This implementation is easily extensible to key payloads as well if there is demand.
296
+
`value_schema_wire_format` and `key_schema_wire_format` apply only to **Avro** payloads. Leave them as `None` when ESM Schema Registry integration has already removed the wire-format header.
0 commit comments