Kafkacat Example

Kafkacat example


You can use any of the available clients to interface with your cluster. In this example we will use a command line producer and consumer called Kafkacat.


Step 1: Get your endpoint

  • From the Eventador console, under deployments, click your Apache Kafka cluster.
  • Switch to the Connections tab.
  • Copy the value in Plain Text Endpoint.
  • Open your terminal and paste BROKERS=<value from plain text endpoint> this value should end in eventador.io:9092

    Note: make sure you have added the IP address of your machine or you will not be able to access your cluster (see “Add an ACL” in the getting started guide).

Step 2: Send some data

Now we’re ready to to send (produce) some data. In producer mode kafkacat reads messages from stdin and produces them to the provided Kafka cluster (-b) and topic (-t). For more information check the kafkacat man

First, let’s double check $BROKERS is set:

Enter the below commands:

Step 3: Consume some data

This time we will use kafkacat to read (consume) from the topic. In consumer mode kafkacat reads messages from a topic and prints them to stdout.

Make sure $BROKERS is still set before starting.

Enter the below command:

You should see the two messages printed out to your terminal

Step 4: More testing

To test our work let’s add a few more messages. Enter the following:

Now let’s read the topic from the beginning again. Enter the below command:

You should see:

Note: Your messages may print in a different order. By default, producers rotate between available partitions. Records are guaranteed to be in order within a partition but when a consumer is subscribed to a topic with multiple partitions messages may be consumed in a different order than they were sent. You can read more about this in the Kafka documentation.

Next Step

Before moving on to build a fully functional client we recommend you follow our guide to setting up your environment to automate environment configuration.

When you’re ready to move away from the command line you can start streaming to/from your applications using you Apache Kafka client of choice. Checkout the examples repo to see some of these clients in action.

Questions, feedback or find any of these steps unclear? Please contact us. We love helping people get started.

Leave a Reply

Your email address will not be published. Required fields are marked *