Deferred External API Call via DB-Backed Queue
A Pub/Sub event consumer that previously made an immediate synchronous call to an external REST API needed refactoring to defer that call by a configurable duration (12 hours). On event receipt, the processor inserts a record into a PostgreSQL queue table with an eligible_after timestamp. A Spring Boot @Scheduled job polls every 5 minutes for eligible records, executes the external API call, and deletes the row on success. Involved: Flyway DB migration, JPA entity/repository, consumer logic modification, and scheduled job implementation. Stack: Java, Spring Boot, GCP Pub/Sub, PostgreSQL, Kubernetes.