Skip to Main Content

Example: Produce & Consume Message

This document provides a step-by-step guide to performing basic message production and consumption tests on an AutoMQ cluster using Kafka CLI tools. The Kafka CLI tools run via the Docker image supplied by AutoMQ.

Prerequisites

Before conducting message transmission tests, ensure the following prerequisites are met:

Complete the installation and deployment of the AutoMQ cluster. You can refer to the following methods for installing and deploying AutoMQ:

Additionally, the host running the test program must fulfill the following conditions:

  • Linux/Mac/Windows Subsystem for Linux

  • Docker

If the previous AutoMQ cluster was deployed according to the guidelines in Deploy Multi-Nodes Test Cluster on Docker▸, the obtained cluster bootstrap address will resemble "server1:9092,server2:9092,server3:9092," and the AutoMQ cluster will be positioned within the "automq_net" Docker network.

Tip

Please substitute the bootstrap-server address below with the actual address of the deployed cluster.

Create Topic


docker run --network automq_net automqinc/automq:latest /bin/bash -c "/opt/kafka/kafka/bin/kafka-topics.sh --create --topic quickstart-events --bootstrap-server server1:9092,server2:9092,server3:9092"

Send Messages


docker run -it --network automq_net automqinc/automq:latest /bin/bash -c "/opt/kafka/kafka/bin/kafka-console-producer.sh --topic quickstart-events --bootstrap-server server1:9092,server2:9092,server3:9092"

Consume Messages


docker run --network automq_net automqinc/automq:latest /bin/bash -c "/opt/kafka/kafka/bin/kafka-console-consumer.sh --topic quickstart-events --from-beginning --bootstrap-server server1:9092,server2:9092,server3:9092"