messaging

Messaging with Apache Kafka

Apache Kafka provides distributed messaging for event-driven architectures. Spring Kafka simplifies producer and consumer implementations. KafkaTemplate sends messages to topics. @KafkaListener consumes messages asynchronously. I configure serializers

PostgreSQL LISTEN/NOTIFY for pub-sub messaging

LISTEN/NOTIFY provides real-time pub-sub messaging. Publishers send notifications via NOTIFY. Subscribers receive notifications via LISTEN. I use it for cache invalidation, real-time updates, inter-process communication. Payloads up to 8000 bytes carr

Idempotent event consumer with processed-events table

At-least-once delivery is the default for most queues and streams, so consumers must be idempotent. My go-to pattern is a processed_events table keyed by event_id with a unique constraint. When a message arrives, the consumer tries to insert event_id;

Redis Pub/Sub subscriber with reconnect-friendly loop

Pub/Sub consumers should assume connections will drop: Redis restarts, network blips, or idle timeouts happen. I keep the subscription loop simple: subscribe, range over the channel, and exit cleanly when ctx.Done() fires. If the subscription ends une