Skip to main content

Send Raw Record : When record from file is sent

Produces a raw (String-serialised) message to a Kafka input topic. The file content is read as-is, with dynamic variables resolved before sending.


Syntaxโ€‹

When record from file is sent
| topicName | file | recordKey | headerFile |
| orders-in | order.json | order-001 | headers.json |
ColumnTypeRequiredDescription
topicNamestringโœ…Name or alias of a declared input topic
filestringโœ…Path to the payload file, relative to the assets directory
recordKeystringโŒKafka record key; omit to send with null key
headerFilestringโŒPath to a JSON file containing Kafka headers ({"headerName": "headerValue"})

File formatโ€‹

The file can contain any text content, JSON, XML, plain text, CSV. KTestify sends it verbatim as the record value (String serialisation). Dynamic variables (e.g. {{DATE:yyyy-MM-dd}}) are resolved before sending.

assets/order.json
{
"orderId": "{{RANDOM:UUID}}",
"createdAt": "{{DATE:yyyy-MM-dd}}",
"product": "Widget A"
}

Headers file formatโ€‹

assets/headers.json
{
"X-Correlation-Id": "abc-123",
"X-Source-System": "order-service"
}

Multiple records in one stepโ€‹

Add multiple rows to the DataTable to produce several records in sequence, in row order:

When record from file is sent
| topicName | file | recordKey |
| orders-in | order-001.json | order-001 |
| orders-in | order-002.json | order-002 |
Same topic required

Every row must resolve to the same physical topic. Mixing topics in one DataTable throws TopicMismatchException before any record is sent, split into separate step invocations instead. See Multi-row DataTables for the full rules (including single-record assertion steps and batch steps).


See alsoโ€‹