Add debezium-cdc module: Debezium 3.7.1 CDC from Postgres 18 to Kafka, Connect vs embedded engine vs outbox
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b5uEyg58znuchZ8C8i
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
e2c42dc268
commit
95e75d0101
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
# The same connector technology, pointed at an outbox table instead of the business table, with the EventRouter SMT.
|
||||
set -eu
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
OUT=output/05-outbox.txt
|
||||
mkdir -p output
|
||||
{
|
||||
echo "### Register the outbox connector (EventRouter single message transform)"
|
||||
register connect/outbox-connector.json
|
||||
wait_running outbox-connector
|
||||
|
||||
echo
|
||||
echo "### One transaction writes the business row AND the outbox row"
|
||||
sql <<'SQL'
|
||||
begin;
|
||||
insert into orders(id, customer, status, amount_cents) values (20, 'zoya', 'NEW', 4200);
|
||||
insert into outbox(id, aggregatetype, aggregateid, type, payload)
|
||||
values ('00000000-0000-0000-0000-000000000020', 'Order', '20', 'OrderCreated',
|
||||
'{"orderId":20,"customer":"zoya","amountCents":4200}');
|
||||
commit;
|
||||
SQL
|
||||
|
||||
echo
|
||||
echo "### A second transaction inserts an outbox row and deletes it before committing (the 'clean up as you go' habit)"
|
||||
sql <<'SQL'
|
||||
begin;
|
||||
insert into outbox(id, aggregatetype, aggregateid, type, payload)
|
||||
values ('00000000-0000-0000-0000-000000000021', 'Order', '21', 'OrderCreated',
|
||||
'{"orderId":21,"customer":"omkar","amountCents":100}');
|
||||
delete from outbox where id = '00000000-0000-0000-0000-000000000021';
|
||||
commit;
|
||||
SQL
|
||||
echo "outbox rows left in the table: $(sql -t -A -c 'select count(*) from outbox')"
|
||||
sleep 5
|
||||
|
||||
echo
|
||||
echo "### Topic outbox.event.Order (headers | key | value; the four __debezium.context.* headers are trimmed with sed)"
|
||||
docker compose exec -T kafka $KT/kafka-console-consumer.sh --bootstrap-server kafka:19092 --topic outbox.event.Order \
|
||||
--from-beginning --timeout-ms 8000 --formatter-property print.headers=true --formatter-property print.key=true \
|
||||
--formatter-property key.separator=' | ' --formatter-property headers.separator=',' --formatter-property headers.deserializer=org.apache.kafka.common.serialization.StringDeserializer 2>/dev/null \
|
||||
| sed -e 's/__debezium\.context\.[A-Za-z]*:[^,]*,//g'
|
||||
|
||||
echo
|
||||
echo "### Topics that exist for this connector"
|
||||
docker compose exec -T kafka $KT/kafka-topics.sh --bootstrap-server kafka:19092 --list 2>/dev/null | grep -E '^(outbox|shopoutbox)' || true
|
||||
} 2>&1 | tee "$OUT"
|
||||
Reference in New Issue
Block a user