Apache Kafka® Quick Start - Confluent Cloud (original) (raw)

1. Sign up for Confluent Cloud

First sign up for a free Confluent Cloud account. You will get $400 in credits when you sign up. To avoid having to enter a credit card, navigate to Billing & payment, scroll to the bottom, and add the promo code CONFLUENTDEV1. With this promo code, you will not have to enter your credit card info for 30 days or until your credits run out.

Next, install the Confluent CLI by navigating to a directory in which to install it and running:

curl -sL --http1.1 https://cnfl.io/cli | sh -s -- latest

Then after installing the CLI log into your Confluent Cloud account by running the following:

confluent login --prompt --save

2. Create a Kafka cluster

Create a Basic Kafka cluster by entering the following command, where is one of aws, azure, or gcp, and is a region ID available in the cloud provider you choose. You can view the available regions for a given cloud provider by running confluent kafka region list --cloud .

confluent kafka cluster create quickstart --cloud --region

For example:

confluent kafka cluster create quickstart --cloud aws --region us-east-1 confluent kafka cluster create quickstart --cloud azure --region eastus confluent kafka cluster create quickstart --cloud gcp --region us-east1

3. Wait for cluster to be running

It may take a few minutes for the cluster to be created. Validate that the cluster is running by ensuring that its Status is Up when you run the following command:

confluent kafka cluster list

For example:

confluent kafka cluster list Id | Name | Type | Provider | Region | Availability | Status ---------------+------------+-------+----------+-------------+--------------+--------- lkc-123456 | quickstart | BASIC | gcp | us-east1 | single-zone | UP

4. Set active cluster

Make your cluster active in the CLI so that you don't need to specify it in later commands:

confluent kafka cluster use

For example:

confluent kafka cluster use lkc-123456 Set Kafka cluster "lkc-123456" as the active cluster for environment "env-123456".

5. Create a topic

Create a topic named quickstart that has 1 partition:

confluent kafka topic create quickstart --partitions 1

6. Create an API key

Create an API key for the cluster that you will use to produce and consume messages:

confluent api-key create --resource

Then set it as the active API key so that you don't need to specify the API key and secret on the command line when producing and consuming messages:

confluent api-key use --resource

7. Produce a message to the topic

Produce a message to the quickstart topic:

confluent kafka topic produce quickstart

Enter the message hello world and then enter Ctrl-C or Ctrl-D to exit:

Starting Kafka Producer. Use Ctrl-C or Ctrl-D to exit. hello world ^C

8. Consume the message from the topic

Now consume the message that you just produced:

confluent kafka topic consume quickstart --from-beginning