PRO

Effect Exactly-Once Consumer

A queue consumer that turns at-least-once delivery into exactly-once effect: it processes first and commits second, so a crash between the two causes redelivery instead of loss, and the dedupe check lives in the same atomic Ref.modify as the side effect, so a redelivered message is recognized, skipped, and committed without a window where it looks unprocessed twice. The demo also plays the wrong ordering (commit-then-process) to show the acknowledged message the broker never redelivers, which is how money disappears silently. Solves the lost message and the double-applied message, the two failure modes on either side of correct commit ordering. Pinned to effect 4.0.0-beta.98.

Install
npx shadcn@latest add https://ui.aryank.space/r/effect-exactly-once-consumer.json

Installs from ui.aryank.space. To add it by hand, copy the files in Files below, or register the @compronents namespace via the docs.

Visualization
ordering
commit offset 1
Effect<void>
apply pay-102
Message
restart
unknown
commit(offset); apply(msg) // crash between = acknowledged and gone

The consumer commits offset 1 and then dies before applying pay-102. The broker's contract is simple: acknowledged work is never redelivered. The restart resumes at offset 2, and 250 dollars is gone with no error, no log line, no retry. Loss is silent by construction.

Files

Dependencies