LESSON 04 · Delivery paths

Hand off through channel workers

Adapt the same intent to push, email, and SMS providers without coupling their failures.

SYSTEM VIEW

The delivery path

Diagram view
Provider ack—
Bounces—
SMS cost—

Watch each channel hand off through its own adapter, see what a provider’s answer doesn’t prove, then weigh a fallback to SMS.

  1. The Push worker pulls an attempt and calls its adapter, a thin module that turns it into one APNs request with the device token. The adapter holds format, credentials, rate rules and response codes, so a new provider leaves ingestion alone.

    Adapter holds
    format, credentials, codes
    One provider
    a plain wrapper is enough

    What changed

    • APNs request with device token
    • Provider details stay in the adapter
  2. The Push service answers accepted, and the Push worker records the provider’s request ID, 7f3a, with that outcome. Accepted means the provider took the request, not that anyone saw it: the phone is offline, and nothing is shown yet.

    Recorded
    req 7f3a · accepted
    Not proven
    seen by the user

    What changed

    • Accepted · req 7f3a recorded
    • Phone offline: nothing shown
  3. The Email worker sends an order receipt, msg 51c2, to the Email provider. Later the address bounces, a separate signal the provider reports to our Callback API. Callbacks are untrusted input, so the API authenticates this one before it counts 1 bounce.

    Sent
    receipt msg 51c2
    Later signal
    bounce callback

    What changed

    • Receipt msg 51c2 sent
    • Bounce callback, authenticated
  4. Amazon SES, for example, can report bounces through SNS, which may deliver a notification more than once. A second copy of the msg 51c2 bounce arrives; the Callback API has already seen it, so the copy changes nothing: still 1 bounce.

    Copies received
    2
    Bounces counted
    1

    What changed

    • Second copy of the bounce
    • Deduplicated: still 1 bounce
  5. The Email provider is down, and 1 million promotional emails wait for the Email worker. Diverting them to the SMS gateway at an example $0.01 a message would cost $10,000 and could bypass SMS consent, so it isn’t automatic: fallback is a product decision.

    If diverted
    1 million emails
    At $0.01 each
    $10,000

    What changed

    • Email provider down
    • 1M promos wait, not diverted
    • SMS gateway: $0.01 a message
  6. Fraud alert n-6620 tries push first. The Push service accepts it, but acceptance isn’t receipt, so the Push worker starts the Fallback wait: 5 minutes for the app to confirm. The time runs out with no confirmation; the phone is still offline.

    Wait
    5 minutes
    Confirmed
    no: phone offline

    What changed

    • Fraud alert n-6620, accepted
    • Fallback wait: 5 minutes
    • No confirmation from the app
  7. After 5 minutes with no confirmation, the policy decides. Fraud alert: its rule allows SMS and the user consented, so the SMS gateway texts it for $0.01 under ID n-6620; a late push then reads as the same alert. Coupon: no fallback rule, no text.

    Fraud alert
    SMS, if consented
    Coupon
    no fallback

    What changed

    • Each message’s rule decides
    • Any SMS keeps ID n-6620
    Message

Space plays · ← → step · Home resets

THE IDEA

How it works

A channel worker pulls eligible attempts from its queue and calls a provider adapter, a thin module that translates one internal request into one provider’s API. Push uses a device token and a platform push service such as Apple’s APNs or Google’s FCM; email uses an email provider; SMS uses an SMS gateway. Adapters isolate request formats, credentials, rate rules, and response codes so a replacement provider does not change event ingestion. With one provider and no plan to switch, a plain wrapper is enough.

The worker records a provider request ID and outcome. A provider acknowledgement means it accepted the request, not that the recipient saw it. Device-token invalidation, email bounces, SMS delivery receipts, and open events are separate later signals with varying reliability. Amazon SES, for example, can report bounces through SNS, which may deliver a notification more than once. Treat provider callbacks as untrusted input: authenticate them and deduplicate repeated status events, so a second copy of one bounce changes nothing.

A fallback channel is a product decision. An email outage should not automatically turn every promotional email into an expensive SMS or bypass consent: at an example price of $0.01 per message, one million diverted emails cost $10,000. If a critical alert permits fallback, define a delay, allowed channels, and a shared notification ID so two successes do not surprise the user. A fraud alert might try push, wait five minutes for the app to confirm receipt, then text a consenting user.

DECISION POINT

The push provider accepts an alert, but the user’s device is offline. Should the system mark it as read or immediately send SMS?

Write a sentence or two to unlock the guidance. Committing first is what makes it stick.

Keep in mind

  • Channel adapters contain provider-specific behavior while queues isolate outages.
  • Provider acceptance, downstream delivery, and user engagement are different observations.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 3
RecallQUESTION 01

What does a provider adapter isolate?

Choose an answer. You’ll see the explanation once you get it right.

Next lesson

0 of 3 checkpoints answered correctly to complete this lesson.