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​