Skip to content
← Free FDE training guides

Free learning / 40-minute Queue 101 lab

Follow a job from accepted to finished

Understand messages, workers and acknowledgements. Compare lost work, duplicated work and a safely reused result with a visual walkthrough and real local database writes.

No account needed. Use your own copy for writing and keep the original as a reference.

Engineering lab library / Run locally

Follow the job. Inspect the effect.

Predict four outcomes, then compare the saved rows. Change the retry identity and see why acknowledgement alone cannot prove the task was done.

Real local SQLite writes with synthetic data. Delivery timing and interruptions are modeled; no broker, cloud account or external effect is used.

  1. Start here / Python 3.11+ · Standard library

    Queue delivery and business effects

    Compare missing, duplicated and reused drafts across four delivery cases; change the replay identity and explain the result.

    Python 3.11+ standard library · Offline synthetic data

Original LockedIn Labs instruction · 40-minute Queue 101 lab · reviewed 21 October 2026.

An engineer asks your application to prepare a maintenance draft. That may take longer than the original web request. A queue lets the application retain the job while a separate worker performs it. It is a software component, not a language, an agent or a promise that the task is finished.

You will follow one fictional job, see why it can arrive twice, and run real local database writes to compare lost work, duplicated work and a reused result. No account, cloud resource, model or payment is required.

1. Meet the message, worker and acknowledgement

UNDERSTAND THE SYSTEM

Follow one job through two deliveries

A queue retains instructions for a worker to process later. Accepting the job, writing its result and acknowledging a delivery are separate events. Follow the fictional J-12 draft to see why a missing acknowledgement does not mean the work never happened.

FOLLOW ONE EXAMPLE

See what moves and why.

Authored illustration
01 / EXPLORE THE PARTSTap a part to explain it
Direction of information or workReturn / feedback

WHAT THIS PART DOES

Request API

The API validates the request and reports acceptance separately from completion.

CONNECTED TO
  • Accept message: Message broker
Read the connections in plain English
  1. 01
    Request API → Message broker

    Acceptance retains the instruction; it does not prove the draft exists.

  2. 02
    Message broker → Worker program

    The worker receives a temporary delivery. This is not an exactly-once business guarantee.

  3. 03
    Worker program → Saved draft

    Write the local effect and its operation receipt together.

  4. 04
    Worker program → Operation receipt

    Match tenant, action and input. A changed input under the same key must conflict.

  5. 05
    Worker program → Message broker

    Confirm that the current delivery was handled after the local result exists.

Check your understanding: If A acknowledges first and then stops before saving the draft, what would the queue know?

It would consider the delivery handled even though there is no draft. The early-ack lab case has a settled message and zero effects. Confirm the intended result before acknowledging; preserve a stable operation identity for retries.

Think of a work-order desk: accepting an order, assigning it to someone and finishing it are different events. In software, a producer submits a message to a queue. A worker receives that message and does the work. An acknowledgement tells the queue that this delivery has been handled.

TermWhat it means hereFamiliar comparison
MessageThe instruction to prepare draft J-12A work order
QueueStorage and delivery of pending messagesThe waiting tray
WorkerA program that handles a messageThe person doing the job
In flightDelivered, with acknowledgement still pendingChecked out of the tray
Visibility period or leaseA bounded interval before work may become available againA temporary assignment
AcknowledgementConfirmation to the broker about this deliveryMarking the order handled
Operation keyStable identity of the intended business actionThe same order number across attempts

The example key is north / J-12:draft:v1. The tenant, job and action stay the same when another worker retries. The delivery receipt changes. A receipt for a delivery and a receipt proving a business effect are different records.

Follow the visual one event at a time. Before advancing, predict both the message state and the number of saved drafts. A queue cannot infer a database commit from silence. A worker can stop after committing the draft but before acknowledging.

2. Run four delivery cases

Download the Python lab into a new working folder. You need Python 3.11 or later. It uses only the standard library.

Code example
python3 --version
python3 fde-queue-delivery-lab.py test
python3 fde-queue-delivery-lab.py demo

The program creates separate temporary SQLite databases and removes them when it finishes. Each event reads committed state through a new database connection. The queue is a small teaching model: expiry uses explicit integer ticks and the interruption is an omitted acknowledgement. No worker is killed and no vendor broker is contacted. The database writes and transaction rollbacks are real.

Make predictions first. Then inspect the final event in each case:

CaseDeliveriesSaved effectsExplanation
normal11Write the draft, then acknowledge.
duplicate-effect22Write, omit acknowledgement, then write again on redelivery.
reuse-effect21Recognize the same action and reuse its committed result.
early-ack10Acknowledge first, then stop before the draft exists.

Notice that both normal and early-ack end with a settled message. A settled queue entry alone cannot demonstrate that the intended business action happened. Keep the trace lines that establish each conclusion.

3. Make the business action safe to repeat

Idempotency means repeating an operation has the same intended effect as doing it once. Here the safe path writes the effect and its receipt in one SQLite transaction. On a repeat, it checks the same tenant, operation key and payload, then reuses the recorded outcome. A changed payload under the same key is a conflict; a different action needs a deliberately different key.

Read apply() in the Python file. BEGIN IMMEDIATE starts the write transaction. The receipt and draft commit together. An exception between them rolls both back. In test_receipt_rolls_back_with_effect, the next attempt can still create the draft because no false success receipt remains.

Experiment in your own copy:

  1. In run_case, change the second call to use operation="J-12:draft:v2". Predict why the safe replay now creates a second effect. Run demo.
  2. Restore it. Change the second call to payload="different draft" instead. Predict and observe operation_conflict in the safe case. The refusal is intentional: it must not silently call changed work a repeat.
  3. Restore the original. Explain why receive(now=4) refuses a new delivery but receive(now=5) permits one in this model. Inspect the boundary test.
  4. Draw the two commits separately: the business effect, then acknowledgement. Mark where the interruption occurs and which evidence the next worker reads.

This model checks the current delivery receipt at acknowledgement time. It does not cancel an old process or fence a remote service. A real service must enforce authorization again at its write boundary and bind replay to the intended input. For an external action such as sending an email, a local receipt and the remote effect do not share a SQLite transaction. Use the destination's supported idempotency and reconciliation contract; an unknown outcome is not permission to send again blindly.

4. Recognize the cloud vocabulary

These are related delivery concepts, not interchangeable APIs. Start with the provider's documented delivery mode and client behavior before choosing retries.

ServiceTemporary delivery stateSuccessful handling
Amazon SQS standard queueVisibility timeoutDelete the handled message
Google Cloud Pub/Sub pull subscriptionOutstanding message with an acknowledgement deadlineAcknowledge the message on that subscription
Azure Service Bus Peek-LockA message lockComplete the message

SQS standard delivery can produce duplicates even during a visibility period. Pub/Sub subscriptions have their own delivery and acknowledgement settings. Service Bus also offers Receive-and-Delete, which has different loss behavior from Peek-Lock. Never translate the local lab into an exactly-once claim about a cloud service or an external business effect.

For your chosen service, record the delivery mode, acknowledgement operation, expiry behavior, bounded retry policy and the owner of repeatedly failing work. A dead-letter destination holds messages for investigation; it does not repair them. Ordering, retention, permissions and operational alerts need explicit decisions too.

Official references checked 21 October 2026:

5. Explain it to the receiving engineer

Keep your four predictions, the actual traces, one changed-key experiment and a diagram showing effect before acknowledgement. Explain the result without using the phrase “the queue handles it.” Name exactly which component recognizes a repeat and what evidence it stores.

Transfer challenge: the draft is now an email sent through another company's API. Your worker times out after submitting it. State what is unknown, how you would query or reconcile the original operation, and when a human must decide. The local transaction is evidence for a local write only.

Continue into the worker recovery lab for actual process interruption, lease fencing and competing workers, or open the guided Queue 101 lesson with your existing training access.

Before you move on

Keep the evidence of your work.

  • Four predictions compared with actual local delivery traces.
  • An operation-key experiment and a diagram separating the effect from acknowledgement.
  • A provider delivery-mode mapping and a plan for an unknown external outcome.

Keep these in your own working copy. Reading this page does not save work or record completion.

Suggested next free session

SDK 101: follow your first client call

Observe what a client SDK sends before integrating a model service. This is a suggested sequence; choose the practice that addresses your current gap.

Open the next free guide
Have Academy access?

Continue with worked explanations, practice and review in the related lesson.

Open the related Academy lesson →
Back to top ↑