The original idea is from
https://medium.com/@kanhaaggarwal/kafka-is-overkill-event-sourcing-with-just-postgres-and-spring-boot-fcd587fea2e2
Enable Logical Replication on PostgreSQL
wal_level = logical max_replication_slots = 10 max_wal_senders = 10
Ensure replication is allowed in pg_hba.conf: host replication your_user 0.0.0.0/0 md5
Then restart Postgres
CREATE PUBLICATION spring_pub FOR TABLE orders, customers;
-- Create a logical replication slot
SELECT * FROM pg_create_logical_replication_slot('spring_slot', 'pgoutput');
or use wal2json if you prefer JSON payloads:
SELECT * FROM pg_create_logical_replication_slot('spring_slot', 'wal2json');
Write Java code to listen to events using PGReplicationStream