Send Avro Record : When record from file based on schema is sent
Produces an Avro-serialised message to a Kafka input topic. KTestify reads the payload from a JSON file, serialises it using the specified Avro schema, and registers the schema in Schema Registry if needed.
Syntaxโ
When record from file based on schema is sent
| topicName | file | schemaName | recordKey |
| orders-in | order.json | Order | ord-001 |
| Column | Type | Required | Description |
|---|---|---|---|
topicName | string | โ | Name or alias of a declared input topic |
file | string | โ | Path to a JSON payload file, relative to assets directory |
schemaName | string | โ | Schema name declared via Given schema; if omitted, resolved via TopicNameStrategy |
recordKey | string | โ | Kafka record key; omit to send with null key |
Payload file formatโ
The payload must be valid JSON that matches the Avro schema fields:
assets/order.json
{
"orderId": "ord-001",
"product": "Widget A",
"quantity": 3,
"createdAt": "{{DATE:yyyy-MM-dd}}"
}
Date fields are normalised automatically by AvroUtils before serialisation.
Schema resolutionโ
KTestify resolves the Avro schema in this order:
- If
schemaNameis set โ looks up subjectschemaName-valuein Schema Registry. - If
schemaNameis empty โ uses TopicNameStrategy:namespace.topicName-value.
Prerequisitesโ
- Schema Registry URL configured:
ktestify.schema-registry.url - Schema declared in Background:
Given schema
| schemaName | schemaAlias |
| Order | order |