Publish Postgres changes to MQTT, Kafka, Clickhouse, etc
Start Postgres and EMQX MQTT broker
curl -OL https://raw.githubusercontent.com/edgeflare/pgo/refs/heads/main/docs/docker-compose.yaml
docker compose up -d
Create a test table, eg users
PGUSER=postgres PGPASSWORD=secret PGHOST=localhost PGDATABASE=testdb psql
CREATE TABLE users (
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY ,
name TEXT
);
Start logrepl
export PGO_POSTGRES_LOGREPL_CONN_STRING=" postgres://postgres:secret@localhost:5432/testdb?replication=database"
export PGO_POSTGRES_LOGREPL_TABLES=users
go build ./cmd/pgo/...
./pgo pipeline --config pkg/config/config.example.yaml
Subscribe
MQTT: /pgcdc/<tableName>
topic (testing with mosquitto client)
mosquitto_sub -t /pgcdc/users # supply additional args eg username,password etc
Kafka: test
topic. use any kafka client eg kaf
echo | kaf produce test # ensusure test topic is created
kaf consume test --follow # consume messages until program execution
INSERT
(or update etc) into users table and notice MQTT subscriber receiving the message
INSERT INTO users (name) VALUES (' alice' );
INSERT INTO users (name) VALUES (' bob' );