A Go-based service that consumes Change Data Capture (CDC) events from MySQL using Debezium connect, Redpanda.
This service implements a consumer that listens to database changes (Create, Update, Delete, Read operations) from MySQL and processes them through a Kafka-compatible message broker (Redpanda). It uses Debezium for CDC (Change Data Capture) integration.
- Go 1.23.2 or later
- Docker and Docker Compose
- MySQL 8.0
- Redpanda
- Debezium Connect
.
├── cmd/main.go # Application entry point
├── consumer/ # Consumer implementation
├── handlers/ # Event handlers
├── scripts/init.sql # Database schema and seed
├── types/ # Type definitions
├── *-connector.json # Debezium connector configuration
├── docker-compose.yml # Docker services configuration
└── go.mod # Go module file
- Clone the repository
git clone https://github.com/AbdelilahOu/Redpanda-go.git
- Start the infrastructure services:
docker-compose up -d
- Create the Debezium connector:
curl -X POST http://localhost:8083/connectors -H "Content-Type: application/json" -d @orders-connector.json
curl -X POST http://localhost:8083/connectors -H "Content-Type: application/json" -d @customers-connector.json
- Run the application:
go run cmd/main.go
- MySQL: Source database (Port: 3306)
- Redpanda: Kafka-compatible message broker (Port: 19092)
- Redpanda Console: Web UI for managing Redpanda (Port: 8080)
- Debezium Connect: CDC connector service (Port: 8083)
The connector is configured to:
- Monitor the
mydb.Orders
table - Publish events to the
orders.mydb.Orders
topic - Use JSON format for messages without schemas
- Track schema changes in a dedicated topic
The Go consumer is configured to:
- Connect to Redpanda broker at
localhost:19092
- Use consumer group
orders-group
- Process messages from the
orders.mydb.Orders
topic - Handle Create, Update, Delete, and Read operations
The service implements handlers for different database operations:
- Create (
c
): Process new record creation - Update (
u
): Handle record updates - Delete (
d
): Process record deletions - Read (
r
): Handle read events