29. Integration patterns: batch, streaming, APIs and sharing
Data moves between systems in five ways: a batch file, change data capture, an event stream, an API call, or not at all, shared in place. Each is fresh to a different degree, costs differently and fails differently; the flow's needs decide.
- Theory 8: Canonical models and integration
- Theory 21: Distributed data: CAP, PACELC and consistency models
- Theory 22: Integration patterns: batch, CDC, events, APIs and sharing
- Theory 23: Streaming: event time, windows, watermarks, exactly-once; Lambda and Kappa
- Theory 24: ETL: transform before you load
- Theory 25: ELT: load, then transform in the platform
- Theory 30: Fan-out: one event, many independent consumers
- Theory 31: Event-driven pipelines: handlers that are safe to retry
- Theory 32: How to choose and combine pipeline patterns
The clip follows one claim reported at 10:14. By event stream, the fraud model sees it seconds later; by change data capture, about five minutes later; by API, whenever someone asks; by the nightly file, at 02:00 the next day. Each lane shows its illustrative daily cost, then how it fails: a late file loses a day, a capture that falls behind loses changes, a stream consumer catches up from its offset, an API fails every caller at once. Last, the reinsurer reads the large losses in place, with nothing copied.
The idea: five patterns, chosen by the flow
- Batch: a file or extract on a schedule. Simple and cheap; as fresh as the last run.
- Change data capture (CDC): read the source database's change log and send every insert, update and delete. Minutes fresh, every change, and the source system does not change.
- Event stream: the source publishes an event for each thing that happens; consumers read the log at their own pace and can replay it. Seconds fresh, but the source must publish events.
- API: the consumer asks for one record when it needs it. Always current, nothing copied, but nothing kept either, and the source must be up.
- Sharing in place: the consumer reads your table where it is, through a share you can revoke. No copy, no pipeline.
Choose by the flow's facts: how fresh it must be, whether it needs every change or only the state, whether the consumer looks one record up, whether the data may leave, and what the source can offer (events, a readable change log, or only a file).
A worked example: six flows after the merger
| Flow | Pattern |
|---|---|
| Claims system to the fraud model: every new claim scored within a minute of first notice. The claims system publishes an event for each claim. | Event stream |
| Policy administration to silver: every change, deletes included, within 15 minutes. The system publishes no events; its database change log can be read. | Change data capture |
| Finance ledger to the board pack: the month's closed figures. The finance team allows only a nightly export file. | Nightly file |
| Broker portal to policy administration: is this customer's policy active, asked once per quote while the broker waits. | API call |
| Gold to the reinsurer: the quarter's large losses, read in the reinsurer's own platform, never copied out of Harbour Mutual's. | Sharing in place |
| Kestrel's claims database to Harbour Mutual's lakehouse during the merger: every change, within the hour. Kestrel publishes no events; its change log can be read. | Change data capture |
The nightly claims extract is a batch pattern at its simplest: everything reported since the last load, 2026-05-11, read with a high-water mark. On the seed it finds 8 claims.
SELECT claim_number, policy_id, loss_date, reported_date, cause, status, reserve
FROM claims
WHERE reported_date > DATE '2026-05-11'
ORDER BY reported_date, claim_number| Pattern | Seen after | Every change | On demand | No copy | Cost a day |
|---|---|---|---|---|---|
| Nightly file | 24 h | no | no | no | 1 |
| Change data capture | 5 min | yes | no | no | 3 |
| Event stream | 3 s | yes | no | no | 4 |
| API call | 0.6 s | no | yes | no | 2 |
| Sharing in place | 0 | no | no | yes | 0.5 |
Why it matters for Alex
Every flow on the merged map will be argued about: the fraud team wants everything in real time, the finance team wants a file it can check, the reinsurer wants a copy it is not allowed to keep. Choosing by the flow's facts gives each the pattern it needs, and a reason Alex can give the board and the engineers alike.
Where it goes wrong
- Real time for everything. Streams built for monthly figures: more to run and more to fail, for nobody's benefit.
- Nightly files for fraud. A claim scored the next morning has already been paid.
- APIs as a data pipeline. Calling an API millions of times to copy a table: slow, fragile, and the source team's outage becomes yours.
- Copies sent outside. Every file sent to a partner is a copy nobody can withdraw; share in place where you can.
Exercises
The lab checks each one against facts written down in advance, so any answer the brief allows passes. A pass is kept in this browser.
The right pattern for six flows
Choose a pattern for each of the brief's flows.
How does it recover?
Each pattern fails in its own way. Choose the recovery for each failure.
On Azure
Each pattern has an Azure form:
- Batch: Azure Data Factory or Fabric Data Factory pipelines, with copy activities and incremental loads by a high-water mark.
- Change data capture: Fabric mirroring keeps a near real-time copy of Azure SQL Database, Azure Cosmos DB, Snowflake and other sources in OneLake; Data Factory's change data capture and Databricks' Lakeflow Connect read source change logs too.
- Event streams: Azure Event Hubs, which also speaks the Kafka protocol; Fabric Eventstream routes events into OneLake and Eventhouse; Databricks reads Event Hubs with Structured Streaming.
- APIs: Azure API Management in front of the system's API, with keys, throttling and logs.
- Sharing in place: Delta Sharing from Azure Databricks (open protocol, any recipient), Fabric's external data sharing between tenants, and OneLake shortcuts inside one.
Write each flow's pattern on the information map's flows (chapter 3), so the map says how the data moves as well as where.
Take it to work
Integration pattern choice
Choose and justify the pattern for each flow.
The flow
- Source, consumer, what is moved
Its facts
- Freshness needed
- Every change or the state
- A lookup on demand?
- May the data be copied?
- What the source offers
The pattern
- Batch, CDC, stream, API or sharing, and why
Failure
- How it fails, and how it recovers
Tools in this chapter
- Stream lab · Run one claims feed as batch, Lambda and Kappa side by side, inject a late correction and replay the log.
Terms taught here: Change data captureBatchEvent streaming