How to Produce Sample Data for a Sink Connector
This guide shows you how to put sample records on a topic through the Rest Proxy, so a sink connector has something to consume when you test it.
Type |
How-to guide |
Goal |
Produce a record onto a topic, from a terminal or from Postman, so a sink connector can be tried end to end. |
Audience |
An application owner testing a sink Connector Application. |
When to use |
Before starting a sink connector for the first time, when the source topic is still empty. |
A sink connector reads from a topic and writes to the integrated system, so it does nothing at all while the topic is empty. Producing a couple of records first is the quickest way to prove the connector works.
Prerequisites
Confirm the following before you begin.
Access and permissions required
You need the following:
-
A registered producer application with produce access to the topic. If you have none, follow Registering a Self-Managed Application and Requesting Topic Access.
-
The certificate and private key of that producer, since the Rest Proxy authenticates callers with mutual TLS.
Resources that must exist before starting
The following must already be in place:
-
The topic the sink connector consumes from, deployed onto the environment you are testing in.
-
The topic name and environment short name.
-
Your Rest Proxy URL, which depends on how the platform was installed:
| Installation | Rest Proxy URL |
|---|---|
Axual Cloud |
Of the form |
SaaS trial |
Stated in the |
Axual Platform on your own infrastructure |
Ask the Axual Platform operators for the address. |
Local Helm deployment |
Replace every <VALUE> placeholder with your own value before running a command.
|
Produce from a terminal
Use curl when you only need to send a record or two.
The example assumes the producer’s certificate and key sit in the working directory as auth.cert and auth.key. Update the first three lines with your own values, then run it.
REST_PROXY_URL="https://rest-ams01.cloud.axual.io:99999"
AXUAL_ENVIRONMENT="example"
AXUAL_STREAM_NAME="my_test_stream"
curl -k --request POST \
--url "${REST_PROXY_URL}/stream/${AXUAL_ENVIRONMENT}/${AXUAL_STREAM_NAME}" \
--header "axual-application-id: irrelevant-for-producers" \
--header "axual-producer-uuid: ${AXUAL_STREAM_NAME}-rest-producer" \
--header "Content-Type: application/json" \
--key ./auth.key \
--cert ./auth.cert \
--data '
{
"keyMessage":{
"type":"STRING",
"message":"{\"name\": \"john\"}"
},
"valueMessage":{
"type":"STRING",
"message":"{\"name\": \"john\", \"age\": \"28\"}"
}
}'
The Rest Proxy produce path is /stream/<environment>/<topic>. The stream segment is part of the API and stays as it is, even though the resource it addresses is called a topic in Self-Service.
|
A successful produce returns HTTP 200 and a ProduceResponse naming the cluster, topic, partition and offset the record landed on.
Produce from Postman
Use Postman when you want to keep the request around and send it repeatedly.
-
Download Postman if you do not already have it installed.
-
Acquire the certificate and key file you used when registering your producer. Configure Postman to send them as a client certificate for mutual TLS, following Manage Postman Certificates.
-
Import the following as a Postman collection:
{ "info": { "_postman_id": "b04bd56b-49cf-4c23-8198-2f22fc8d5d72", "name": "Axual Platform produce example", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [{ "name": "Produce event", "protocolProfileBehavior": { "disabledSystemHeaders": { "user-agent": true, "accept": true, "accept-encoding": true, "connection": true }, "strictSSL": false }, "request": { "method": "POST", "header": [ { "key": "axual-application-id", "value": "irrelevant-for-producers", "type": "default" }, { "key": "axual-producer-uuid", "value": "{{AXUAL_STREAM_NAME}}-rest-producer", "type": "default" } ], "body": { "mode": "raw", "raw": "{\n \"keyMessage\":{\n \"type\":\"STRING\",\n \"message\":\"{\\\"name\\\": \\\"john\\\"}\"\n },\n \"valueMessage\":{\n \"type\":\"STRING\",\n \"message\":\"{\\\"name\\\": \\\"john\\\", \\\"age\\\": \\\"28\\\"}\"\n }\n}\n", "options": { "raw": { "language": "json" }} }, "url": { "raw": "{{REST_PROXY_URL}}/stream/{{AXUAL_ENVIRONMENT}}/{{AXUAL_STREAM_NAME}}", "host": [ "{{REST_PROXY_URL}}" ], "path": [ "stream", "{{AXUAL_ENVIRONMENT}}", "{{AXUAL_STREAM_NAME}}" ] } }, "response": [] }], "event": [], "variable": [ { "key": "REST_PROXY_URL", "value": "https://rest-ams01.cloud.axual.io:99999", "type": "default" }, { "key": "AXUAL_ENVIRONMENT", "value": "example", "type": "default" }, { "key": "AXUAL_STREAM_NAME", "value": "my_test_stream", "type": "default" } ] } -
Open the
Variablestab of the collection and set the three variables to your own values. Save the collection. -
Send the
Produce eventrequest to publish a record.
Related pages
-
Rest Proxy API describes the produce service and its request and response objects.
-
ProduceRequest and ProduceResponse give the exact payload shapes.
-
Example: Producing data with Rest Proxy covers producing outside the connector context, including Avro payloads.
-
Managing Connector Applications covers starting the sink connector once the topic has data.