This repository is a Next.js application that showcases the integration of Ably and Confluent through Ably's Kafka Connector and Confluent Custom Connectors. Features include:
- Ably's React Hooks for real-time updates in the front end
- Confluent Custom Connectors for Kafka streams
- A comprehensive step-by-step guide for setting up and running the application
- Terraform scripts for configuring the Confluent Cloud resources
- Ably-Confluent Kafka Connector with Next.js
- Overview
- Table of Contents
- Prerequisites
- Getting Started
- Cleaning up
- Architecture
- Built With
- Learn More About Next.js
- Ably Account
- Confluent Account
- Terraform installed
- Node.js and npm installed
- Basic understanding of React, Next.js, and Kafka
Follow these steps to get the application up and running.
- Navigate to Ably and sign up for an account.
- Navigate to Confluent and sign up for an account.
- Make a copy of the
.env.examplefile and rename it to.env.localthen populate it with your Ably key.
- Navigate to the Ably Dashboard.
- Click on the key you want to use.
- Copy the API key.
- Paste the API key value in the
.env.localfile for the keyABLY_API_KEY
-
Initialize and apply the Terraform script.
terraform init terraform apply
-
Enter you Cloud API Key and Secret as prompted
-
Type
yesto confirm that you would like to run the Terraform script -
This script will create the following resources in Confluent Cloud:
- A Confluent Cloud Environment
- A Basic Cluster
- A Schema Registry Instance
- A Service Account
- A topic called Orders
- A Datagen Source Connector
- Obtain the .zip of the connector as per Ably's manual installation guide.
- Log in to your Confluent Cloud account and inside the cluster on your Confluent Cloud account go to the Connectors tab and click on
Add Connector - Instead of selecting Ably Kafka Connector from the Hub, instead click
Add Plugin - Give the plugin a name, and set the class to com.ably.kafka.connect.ChannelSinkConnector
- Select
Sink Connector - Upload the .zip file you obtained in step 1 by clicking on
Select connector archive - Click on
Applyto upload the connector plugin
- Navigate back to the Connectors tab and select the plugin name you uploaded in the previous step to luanch the connector configuration and deployment
- Select
Generate API key & downloadto create a Global API key for the connector - Select the option to configure your connector via JSON and insert the following, replacing the placeholder with your Ably API key:
{
"connector.class": "com.ably.kafka.connect.ChannelSinkConnector",
"tasks.max": "1",
"group.id": "ably-connect-cluster",
"topics": "orders",
"client.id": "Ably-Kafka-Connector",
"channel": "#{topic}",
"message.name": "#{topic}_message",
"client.key": "<YOUR_ABLY_API_KEY>",
"key.converter": "org.apache.kafka.connect.converters.ByteArrayConverter",
"value.converter": "org.apache.kafka.connect.converters.ByteArrayConverter",
"value.converter.schemas.enable": "false"
}- When asked for an endpoint, enter
rest.ably.io:443:TCP - Continue with the remaining steps of the connector configurations with the default selections and launch the connector
npm install
npm run dev- To delete the custom connector:
Go back to the Connectors tab on your Confluent Cloud cluster, select the custom connector, navigate to it's Settings tab and select Delete Connector. Note: The Datagen Connector will be deleted with the rest of the Confluent Cloud environment in the next step.
- To tear down the Confluent Cloud environment:
Run the following command on your terminal and confirm by typing "yes" when prompted. You will once again need to provide your Cloud API key and secret:
terraform destroy
- Ably React Hooks
- Confluent Custom Connectors
- Terraform
- NextJS
For more information about Next.js, check: