Chapter II · Area 07 of 12

Communication & APIs

The Question for Our ShopMust checkout wait until the invoice PDF is ready?

Here you will learn how system parts exchange data and work together reliably.

23 Building blocks

Starting hereAPI contracts

Three questions for every collaboration

  1. What is promised, and who gets in?

    Contracts & access

    Warehouse promises reservation R-77 for B-1042; the field expiresAt is added in a compatible way.

  2. Does the caller wait for a response?

    Temporal coupling

    Order asks warehouse directly; invoice accepts the job, OrderPaid goes to shipping and analytics.

  3. What happens on retries and failures?

    Reliability

    pay-B-1042 prevents double charging; the outbox holds OrderConfirmed until the channel is reachable again.

Known names – and where they are

This is how the building blocks hang together

API contracts define the commitments. Synchronous and asynchronous communication use them, queues and pub/sub distribute messages. Idempotency secures retries, the outbox secures publication, orchestration runs processes. The gateway controls access, versioning controls evolution.

ConceptAPI contractsAPI contracts define data, meaning and observable interface behavior as binding rules.PatternSynchronous communicationuses API contracts for responses, errors and timing behaviourPatternAsynchronous communicationuses API contracts for message structure, meaning and statesConceptIdempotencykeeps the business effect stable when the same job is repeatedDecision spaceMessaging: Queues, Publish/Subscribe & Streamsdistribute messages whose form and meaning are defined by the contractMechanismAPI versioningevolves contracts with clear compatibility and migration rulesPatternTransactional Outboxpublishes events whose form and meaning are defined by the contractDecision spaceOrchestration & choreographycontrols processes via interfaces whose commitments are defined by the contractPattern familyAccess, Mediation & Service Discoveryroutes external requests according to the commitments of the contract
Relations: Synchronous communication uses API contracts for responses, errors and timing behaviour; Asynchronous communication uses API contracts for message structure, meaning and states; Idempotency keeps the business effect stable when the same job is repeated; Messaging: Queues, Publish/Subscribe & Streams distribute messages whose form and meaning are defined by the contract; API versioning evolves contracts with clear compatibility and migration rules; Transactional Outbox publishes events whose form and meaning are defined by the contract; Orchestration & choreography controls processes via interfaces whose commitments are defined by the contract; Access, Mediation & Service Discovery routes external requests according to the commitments of the contract.

Your learning path through the area

Here you clarify whether checkout has to wait for the invoice, what callers are promised and how retries and changes stay reliable. Each building block shows its theme at our shop.

  1. API contracts

    Standalone conceptContract

    This is what you learnYou can name mandatory fields, results and errors of a storage reservation as a contract.

    In the shopOrder reserved on the contract of the storage module two cups for B-1042. The reservation has a stable identifier and an expiration date.

    API contracts Open
  2. This is what you learnYou want to test provider changes against real consumer expectations and must organize expectations, verification, publication, and version selection. You can compare the three central guarantees.

    In the shopThe current shop remains a modular monolith with seven modules. Order consumes Payment’s internal contract for authorization status and rejection reason. The Order team publishes a contract with success and rejection examples; Payment verifies it in the pipeline for every change. For a hypothetical later service split, contract, provider version, and deployment environment are published together. The team deliberately changes a field that became optional and checks that only expectations actually in use block release.

    Consumer-Driven Contract Testing Open
  3. Synchronous communication

    Overview & comparisonTemporal coupling

    This is what you learnIn the checkout, you can mark which calls the order process immediately awaits a response.

    In the shopIn modular monoliths, ordering requests warehouse and payment directly. The payment module calls the external payment provider via the network.

    Synchronous communication Open
  4. Asynchronous communication

    Overview & comparisonTemporal coupling

    This is what you learnYou can separate acceptance, later processing and visible status of an invoice order.

    In the shopAfter confirmed order, invoice accepts an order and creates the receipt later. The checkout does not have to wait for the finished PDF.

    Asynchronous communication Open
  5. claim-check

    Standalone concept

    This is what you learnYou can design reference, storage authorization, integrity, retention, and cleanup as one claim-check contract.

    In the shopThe current shop processes its seven modules in a modular monolith. For a hypothetical external shipping service, Invoice creates a PDF, stores it encrypted under an opaque identifier, and sends order ID, object identifier, media type, and checksum through the broker. Shipping retrieves the document using its own service identity. The team delays the message beyond the normal URL lifetime, tests redelivery, and proves controlled renewal plus cleanup only after business completion.

    claim-check Open
  6. Event Stream

    Standalone concept

    This is what you learnYou can explain partition ordering, offset, retention, and replay as one stream contract.

    In the shopThe current shop remains a modular monolith with seven modules. For a hypothetical analytics platform, order events are partitioned by order ID and retained for 90 days. Shipping reads live with its own group; Analytics builds a projection from its offset. The team deletes the analytics projection, replays available history, and checks per-order ordering, schema capability, and idempotent processing. It explicitly documents which view could only recover from a snapshot after retention expires.

    Event Stream Open
  7. Publish-Subscribe

    Standalone concept

    This is what you learnYou can distinguish pub/sub from a work queue and event stream and define an operating contract per subscription.

    In the shopIn the current shop, seven modules run together. Hypothetically, Order publishes OrderPaid after confirmed payment. Shipping, Customer Notification, and Analytics each receive a delivery through separate subscriptions and retain their own position and failures. The team takes Analytics offline, publishes more events, and proves that Shipping progresses, Analytics catches up, and duplicate delivery causes no duplicate business effect.

    Publish-Subscribe Open
  8. Queue

    Standalone concept

    This is what you learnYou can define queue contract, acknowledgement point, backlog limit, and failure channel.

    In the shopThe shop remains a modular monolith with seven modules. Hypothetically, Order places an invoice-generation job on the existing broker queue after commit. A worker creates and stores the invoice, then acknowledges. The team stops the worker before acknowledgement, fills the queue faster than it is processed, and tests idempotency, oldest-message age, capacity limit, and dead-letter path. Only this evidence supports the asynchronous extension.

    Queue Open
  9. Competing Consumers

    Standalone concept

    This is what you learnYou can design competing workers with locks, acknowledgements, idempotency, and scaling metrics.

    In the shopThe current shop creates invoices in a modular monolith with seven modules. Hypothetically, Order places invoice jobs on a queue read competitively by four workers. Order ID and invoice version form the idempotency key. The team terminates a worker after storing the PDF but before broker acknowledgement; after lock expiry, another worker takes over, detects the existing effect, and acknowledges without a second invoice. Queue age and duration control worker count.

    Competing Consumers Open
  10. Priority Queue

    Standalone concept

    This is what you learnYou can design priority classes, fairness, and measurable waiting-time objectives.

    In the shopThe existing shop processes seven modules in a modular monolith. For hypothetical asynchronous invoice generation, legally required corrections are urgent and normal first invoices are regular. Two of ten processing slots remain reserved for regular work; its priority increases after a defined wait. The team generates urgent jobs for an extended period and proves throughput, oldest-message age, and met waiting time for both classes before adopting the rule.

    Priority Queue Open
  11. Idempotency

    Standalone conceptReliability

    This is what you learnYou can predict when repeated calls will trigger the same or a new business impact.

    In the shopThe payment module sends B-1042 with the key pay-B-1042 to the external provider. The first answer is lost.

    Idempotency Open
  12. Transactional Outbox

    Standalone conceptReliability

    This is what you learnYou can show how the order and the publishing order are stored together and later shipped separately.

    In the shopVariant with permanent news channel: order confirmed B-1042 and at the same time stores order confirmed in your outbox. The news channel is temporarily unreachable.

    Transactional Outbox Open
  13. Orchestration & choreography

    Overview & comparisonReliability

    This is what you learnFor reservation and payment, you can distinguish between orchestration and choreography.

    In the shopVariant: Warehouse and payment are independent services. The team compares an order orchestration with an event-driven choreography; the payment provider remains external.

    Orchestration & choreography Open
  14. Choreography

    Standalone concept

    This is what you learnYou can design event chain, correlation, and overall status for a choreography.

    In the shopThe current shop processes B-1042 as a modular monolith with seven modules and a shared database: reserve stock, authorize payment, confirm the order, commission shipping. The visual compares a hypothetical distributed saga using event reactions and central commands. A shipping rejection triggers compensations only through explicitly designed reactions: cancel the order, cancel the authorization, and release stock.

    Choreography Open
  15. Orchestration

    Standalone concept

    This is what you learnYou can model orchestrator state, participant boundaries, and flow recovery.

    In the shopThe current shop processes B-1042 as a modular monolith with seven modules and a shared database: reserve stock, authorize payment, confirm the order, commission shipping. The visual compares a hypothetical distributed saga using central commands and event reactions. A shipping rejection leads to explicitly designed business operations: cancel the order, cancel the authorization, and release stock.

    Orchestration Open
  16. Access, Mediation & Service Discovery

    Overview & comparisonContract

    This is what you learnYou can assign external shop routes to the relevant internal destinations via an API gateway.

    In the shopVariant: Catalogue and shipping were separated as services for proven operational reasons. Browser and customer service access shop routes exclusively via the API gateway.

    Access, Mediation & Service Discovery Open
  17. Service Discovery

    Standalone concept

    This is what you learnYou must map a logical service name to currently reachable instances and define freshness, health checking, and cache behavior. You can compare the three central guarantees.

    In the shopThe current shop has seven modules in one process. Hypothetically, Shipping runs on three changing instances behind the logical name shipping. The platform publishes endpoint changes and removes a faulty instance according to its health rule. The team stops one instance during traffic and measures time to removal, failed attempts from caches, and behavior during discovery outage. Only a bounded stale period and successful re-resolution support the guarantee.

    Service Discovery Open
  18. service-mesh

    Standalone concept

    This is what you learnYou must implement shared rules for internal service communication and operate the added data and control paths. You can compare the three central guarantees.

    In the shopThe current shop remains with seven modules in one process and does not need a mesh. For hypothetical separate Order, Payment, and Shipping services, a mesh data plane mediates mTLS, telemetry, and traffic rules. The team rotates certificates, disconnects the control plane, and forces a target outage. It measures added p95 latency, connection errors, and behavior with last known configuration before the platform complexity is justified.

    service-mesh Open
  19. API Gateway

    Standalone concept

    This is what you learnYou must create a controlled external entry point for several APIs and define routing, access control, and failure behavior at the edge. You can compare the three central guarantees.

    In the shopThe current shop remains a modular monolith with seven modules. Hypothetically, Browser and Customer Service receive separate public routes through a gateway to Catalog and Shipping. The gateway checks identity, rate limit, and deadline and routes to registered targets. The team simulates an unreachable target and invalid authorization and proves unambiguous status codes, correlation ID, bounded retry, and unchanged internal contracts.

    API Gateway Open
  20. Backend for Frontend

    Standalone concept

    This is what you learnYou can bound BFF responsibility by client need and recognize duplicated business logic.

    In the shopThe current shop has seven modules and a web interface in a modular monolith. A hypothetical mobile app needs smaller product images, a compact order summary, and fewer round trips; a Mobile BFF aggregates Catalog and Order for that purpose. The web interface continues to use its existing server-side adapter. Prices, reservations, and payment status are decided exclusively by the responsible modules. The team measures payload size, call count, and change rate before operating the additional service permanently.

    Backend for Frontend Open
  21. API versioning

    Standalone conceptContract

    This is what you learnYou can distinguish a compatible API extension from a breaking meaning change.

    In the shopThe warehouse module extends the reservation response with expiresAt. Later, the existing field available should change from a number to a business availability level.

    API versioning Open
  22. API composition

    Standalone concept

    This is what you learnYou can compare runtime composition and a read model using fan-out, freshness, and partial failures.

    In the shopThe current shop has seven modules in a modular monolith and one shared database. Customer service needs an order view from Order, Payment, and Shipping. An internal composer calls the three module APIs in parallel, limits each subrequest, and marks a missing shipping status as temporarily unknown. Network failures arise only in a hypothetical later service split; p95 latency, fan-out, and partial-result measurements then determine whether a materialized read model is preferable.

    API composition Open
Afterwards in the learning path · area 08Distributed systems

Connections to other areas

These concepts complement this area’s perspective. Their full explanations are available through their primary subject area.