Ask, Announce or Hand Over: Picking the Right Integration Style
"Should this be event-driven?" is a question I hear a lot, usually because events are in fashion. The better question is: what does the consumer actually need?
Ask: synchronous APIs
Use an API when a consumer needs an answer now and cannot continue without it. Checking stock before confirming an order. Validating an address while the user types. The cost: both systems must be up at the same time, and a slow provider makes the consumer slow.
Announce: events
Use events when something happened that several consumers may care about, and the source should not need to know who they are. An order was created, an asset was changed, an employee joined. Each consumer reacts in its own time. The cost: the overall flow is harder to see, so you need good monitoring and well-defined events. An event nobody subscribes to is just a log message with a budget.
Hand over: files and batches
Batches are not old-fashioned, they are honest. If the business process runs daily, like bank statements or payroll, a well-run nightly transfer is simpler and cheaper than a stream of events. The cost: data is only as fresh as the last run.
A quick test
- Does the consumer wait for the answer? Ask.
- Do several consumers react to the same change? Announce.
- Does the business work in cycles? Hand over.
Most real landscapes need all three. The skill is not choosing a favourite, it is choosing per use case and then doing each one well: one way to secure, monitor and document every style.