Free · Local simulation · Intermediate
Pub/Sub delivered it again—why did revenue increase?
Repair a payment-event consumer. Choose when to acknowledge a delivery and how to identify a business event, then recover from a failed write and a crash after commit.
This browser simulation uses fictional Pub/Sub v1 pull deliveries and an atomic local ledger. Prerequisites are keys, event and order grain, queues and retries.
Consumer policy and delivery
ackTiming accepts before_write or after_write. dedupKey accepts none, message_id, event_id, producer_event_id or order_id.
The first m1 delivery fails before write. The first m2 delivery crashes after commit. Expiry is a manual action.
Edit the policy or process the first pending delivery.
Forced post-ACK redelivery
An explicit fixture gives an acknowledged message a new delivery ACK ID.
Confirmed state
0 cents · 0 ledger rows
- Pending
- m1, m2, m3, m4
- In flight
- None
- Retry ready
- None
- Acknowledged
- None
- Next action
- Process the next publication
| Message | Producer | Event | Order | Cents | Commit ACK ID |
|---|
Zero rows.
Full confirmed state, ACK receipts and attempts
Source publications
In the original example, m2 and m3 publish the same business event. m1 and m4 are distinct payments for the same order. The reference ledger has three rows and totals 6,000 cents. Source edits take effect after you confirm a baseline reset.
| Message | Producer | Event | Order | Cents |
|---|---|---|---|---|
| m1 | shop | e1 | o10 | 1000 |
| m2 | shop | e2 | o20 | 2000 |
| m3 | shop | e2 | o20 | 2000 |
| m4 | shop | e3 | o10 | 3000 |
Use up to 100 publications with unique message IDs, nonblank IDs of 1–40 characters and integer cents from 0 to 2,147,483,647. Publications of one producer and event pair must agree on the order and amount.
Actual trace
Process a delivery to inspect its effects.
Expected states
Inspect the disclosed inputs and full expected state for each action. Choose a case and step to compare all state fields with your current run.
Fault sink failure before write. SinkFailed.
The current state differs from this step.
| Message | Producer | Event | Order | Cents | Commit ACK ID |
|---|
Zero rows.
Case publications
Full expected state and provenance
Hints and worked policy
Use a hint when you need it.
Reflection: why can two separate publications still duplicate a payment even when transport delivery is scoped to a message ID? Use the expected states to check this exercise.
Pub/Sub service references and simulation rules
The simulator chooses the oldest pending publication, allows one active delivery, and models successful ACK operations. The ledger and deduplication decision commit atomically within this exercise.
- Default at-least-once delivery and no guaranteed order; deadline expiry can permit redelivery, and a duplicate can occur even after a successful ACK. Google Cloud documentation
- Exactly-once delivery is pull/regional/message-ID scoped; retry of a published message retains its message ID. This does not merge distinct publications of one business event. Google Cloud documentation
- Acknowledge takes delivery ackIds returned by pull; an expired acknowledgment does not safely imply permanent removal under ordinary delivery. Google Cloud documentation
Save on this device
Save your drafts, ledger, ACKs and trace in this browser.
Reading this device’s saved copy…
The worker has 5 seconds to load and 1 second to execute. Each editor allows 60,000 UTF-8 bytes. The serialized worker request and saved copy each allow 300,000 bytes. Results include confirmed state and up to 512 trace actions within 160,000 bytes.