Skip to content

Trace gateway queue capacity, poison messages and replay

Apply a bounded queue, transformation contract, duplicate filter, dead-letter route and replay to a supplied fictional event fixture.

Use the Integration and Gateways message-queuing route to inspect how a bridge maps source records, preserves meaning and handles failures., your practice guide

Use the Integration and Gateways message-queuing route to inspect how a bridge maps source records, preserves meaning and handles failures.
Predict the reading, then compare it with the measurement.

Python 3 in your browser (JupyterLite)

Python · no install

Apply a bounded queue, transformation contract, duplicate filter, dead-letter route and replay to a supplied fictional event fixture.

Tier 2 · Web · paste-in setup · No account

Version tested: Python 3.12.7 / Pyodide 0.27.6 in JupyterLite 0.6.4; Chromium 151.0.7922.34; captureSource playwright:jupyterlite. Date: 2026-10-08.

Open the notebook in your browser and run each Python cell; no install or account is needed.

Three ways to run: use JupyterLite here with no install; run main.py locally from the downloadable lab folder; or open the same notebook in Google Colab.

Open in your browser (new tab)

Steps

Screens captured against Python 3 in your browser (JupyterLite) Python 3.12.7 / Pyodide 0.27.6 in JupyterLite 0.6.4; Chromium 151.0.7922.34; captureSource playwright:jupyterlite on 2026-10-08; the tool may have moved on — the text steps are the contract.

  1. 1 Step 1

    Do
    In the notebook editor, run the Step 1 notebook cell. Freeze and hash the fictional source-event fixture.
    You will see
    The run prints six events including a duplicate e2 and malformed e3, plus a SHA-256 prefix.
    Why it matters
    A replay result needs a fixed source input.
    JupyterLite notebook Step 1 output from the executed Python cell.
    Step 1 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  2. 2 Step 2

    Do
    In the notebook editor, run the Step 2 notebook cell. Fill a capacity-three intake queue.
    You will see
    The fourth event e3 meets backpressure; draining e1 frees a slot.
    Why it matters
    Capacity pressure needs an explicit admission policy.
    JupyterLite notebook Step 2 output from the executed Python cell.
    Step 2 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  3. 3 Step 3

    Do
    In the notebook editor, run the Step 3 notebook cell. Validate and deduplicate the six events.
    You will see
    The output marks e2 duplicate and e3 dead-letter while accepting e1, e2, e4 and e5.
    Why it matters
    Bad records must not block later valid records.
    JupyterLite notebook Step 3 output from the executed Python cell.
    Step 3 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  4. 4 Step 4

    Do
    In the notebook editor, run the Step 4 notebook cell. Translate accepted meter records.
    You will see
    The output maps e1 to plant/meter-a/power with watts 120 and unit W.
    Why it matters
    A reviewable bridge specifies target topic, unit and idempotency key.
    JupyterLite notebook Step 4 output from the executed Python cell.
    Step 4 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  5. 5 Step 5

    Do
    In the notebook editor, run the Step 5 notebook cell. Quarantine the poison record.
    You will see
    The dead-letter entry says id=e3 reason=invalid_watts attempts=1.
    Why it matters
    Unbounded retries of malformed input cause queue failure.
    JupyterLite notebook Step 5 output from the executed Python cell.
    Step 5 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  6. 6 Step 6

    Do
    In the notebook editor, run the Step 6 notebook cell. Replay the corrected event once.
    You will see
    The run reports five unique accepted IDs after correction, one duplicate and one repaired dead letter.
    Why it matters
    Replay must preserve identity and show reconciliation counts.
    JupyterLite notebook Step 6 output from the executed Python cell.
    Step 6 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)

Chapter checks

These questions refer to the chapter’s examples. Use the return links to review their answers.

  1. A bridge has a retained command and a rejected message. What two failure paths need explicit policy?

    Return to the chapter’s knowledge check
  2. A team sets the highest QoS so that each command runs exactly once across the whole pipeline. Why is QoS alone not sufficient?

    Return to the chapter’s knowledge check

Caution

The fixture and queue are a deterministic Python model, not broker traffic. Confirm acknowledgements, persistence and crash recovery in a real gateway.

Return to Pub/Sub and Topic Routing · Browse Labs