kafka-console-avro-tools

command module
v0.2.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Kafka Avro Producer and Consumer

This application demonstrates how to use Kafka with Avro serialization and deserialization. It includes a producer and a consumer that can send and receive Avro-encoded messages using the Confluent Schema Registry.

Prerequisites

  • Go 1.16 or later
  • Kafka cluster with Confluent Schema Registry

Dependencies

Usage

Build

To build the application, run the following command:

go build -o kafka-avro
Producer

To run the producer, use the following command:

./kafka-avro producer [flags]

Flags:

  • -t, --topic: Name of the topic (default: "output")
  • -b, --brokerList: Kafka broker list (default: "localhost:9092")
  • --schemaId: Schema ID
  • --schemaRegistryURL: Schema Registry URL (default: "http://localhost:8081")
  • -m, --msg: Message
  • -f, --file: Filename
  • -a, --auth: Auth type (default: "wo"). Supported options:
    • wo - without authentication
    • tls - TLS/SSL authentication
  • --certFile: TLS certificate file (in pem format) (default: "./client.cer.pem")
  • --keyFile: TLS key file (in pem format) (default: "./client.key.pem")
  • --caCertFile: TLS CA certificate file (in pem format) (default: "./server.cer.pem")
Consumer

To run the consumer, use the following command:

./kafka-avro consumer [flags]

Flags:

  • -t, --topic: Name of the topic (default: "output")
  • -b, --brokerList: Kafka broker list (default: "localhost:9092")
  • -g, --group: Consumer group (default: "kafka-console-avro-tools")
  • --schemaRegistryURL: Schema Registry URL (default: "http://localhost:8081")
  • -a, --auth: Auth type (default: "wo"). Supported options:
    • wo - without authentication
    • tls - TLS/SSL authentication
  • --certFile: TLS certificate file (in pem format) (default: "./client.cer.pem")
  • --keyFile: TLS key file (in pem format) (default: "./client.key.pem")
  • --caCertFile: TLS CA certificate file (in pem format) (default: "./server.cer.pem")
Testing
  1. Register simple Avro schema
curl -s -L 'http://localhost:8081/subjects/Kafka-value/versions' \
-H 'Content-Type: application/vnd.schemaregistry.v1+json' \
-d '{"schema": "{\"type\":\"record\",\"name\":\"Record\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"address\",\"type\":\"string\"}]}"}'
  1. Produce a message to kafka topic
./kafka-avro producer --schemaId=1 --file examples/example.json
  1. Consume messages from kafka topic
./kafka-avro consumer
License

This project is licensed under the MIT License.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址