This example allows a protobuf object to be sent to a REST edpoint as JSON that gets validated and converted to the protobuf when it is produced onto Kafka.
To start
the Docker Compose stack defined in the compose.yaml file, use:
docker compose up -d
Open the Kafka UI or run the kafkacat command:
docker compose -p zilla-http-kafka-proto-oneway exec kafkacat \
kafkacat -b kafka.examples.dev:29092 -C -f 'Key:Message | %k:%s\n Headers | %h \n\n' -t my-requests
echo "message:'hello world',count:10" \
| protoc --encode Request ./request.proto \
| curl -s --request POST http://localhost:7114/requests \
--header "Content-Type: application/protobuf" \
--data-binary @-
echo "message:'hello bad type',count:'ten'" \
| protoc --encode Request ./request_bad_type.proto \
| curl -s --request POST http://localhost:7114/requests \
--header "Content-Type: application/protobuf" \
--data-binary @-
echo "message:'hello extra field',count:10,extra:'field'" \
| protoc --encode Request ./request_extra_field.proto \
| curl -s --request POST http://localhost:7114/requests \
--header "Content-Type: application/protobuf" \
--data-binary @-
echo "message:'hello wrong order',count:10" \
| protoc --encode Request ./request_wrong_order.proto \
| curl -s --request POST http://localhost:7114/requests \
--header "Content-Type: application/protobuf" \
--data-binary @-
To remove any resources created by the Docker Compose stack, use:
docker compose down