Skip to Main Content

Example: Produce & Consume Message

This article provides a straightforward walkthrough for sending and receiving messages, allowing you to test the core features of AutoMQ.

After successfully installing AutoMQ via Cluster Deployment on Linux▸, you'll receive a set of Bootstrap Server addresses that look something like this:

192.168.0.1:9092,192.168.0.2:9092

If you opted for Deploy Locally▸, your Bootstrap Server address will be:

broker1:9092,broker2:9092

Make sure to replace the Bootstrap Server address with the actual one you have during all steps.

Prerequisites

  • Linux/Mac/Windows Subsystem for Linux

  • Docker

If the container image download is slow, please consult Docker Hub Mirror Configuration▸

Create Topic


CMD='docker run --network automq_net automqinc/automq:latest /bin/bash -c "/opt/kafka/kafka/bin/kafka-topics.sh --create --topic quickstart-events --bootstrap-server broker1:9092,broker2:9092"'; [ "$(uname)" = "Linux" ] && eval "sudo $CMD" || eval $CMD

Send Message


CMD='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 broker1:9092,broker2:9092"'; [ "$(uname)" = "Linux" ] && eval "sudo $CMD" || eval $CMD

Consume Message


CMD='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 broker1:9092,broker2:9092"'; [ "$(uname)" = "Linux" ] && eval "sudo $CMD" || eval $CMD