Short answer: an Express endpoint should record an edtech cleanup request and its outbox event in one Postgres transaction, return 202 Accepted , and let a separate worker publish and consume a small job. The worker should claim work with a lease, make each deletion decision idempotent, and write the audit event before acknowledging the delivery. That arrangement keeps a web request short while making recovery inspectable.
The constraint comes first. A student-record cleanup can touch thousands of rows, object references, and retention exceptions; keeping the browser request open turns a normal timeout or deploy into an ambiguous business event. The API is therefore an admission point, not the executor. The queue is delivery machinery, not the system of record.
There is no magic exactly-once execution guarantee.…