Overview

10 When hexagons talk: Integration modes and the external architecture

This chapter explains how a hexagon fits into a larger system by making every external interaction explicit. Using WriteFlow and its partners, it shows that the boundary is where direction, meaning, timing, and ownership become visible: an outside system may drive WriteFlow with a request, WriteFlow may drive another system, or a coordinator may manage a longer process that spans several systems. The key idea is to treat these choices as design decisions made by the team, not as details hidden inside the domain model, and to record them clearly so the architecture can evolve safely.

The text distinguishes inbound from outbound integration, then separates requests from facts. A request asks for work or information and may require an immediate answer, while a fact reports that something has already happened and can be published for others to react to later. From there, the chapter presents three integration modes: synchronous calls, event-driven integration, and external orchestration. Synchronous calls are simple but create time coupling; events support loose coupling and eventual consistency but require tolerance for duplicates and reordering; orchestration is needed when a multi-step process must survive failures, with a durable coordinator owning sequencing, retries, and compensation.

Across all modes, the same rules hold: the domain decides what is allowed, the application layer decides what leaves the hexagon, and adapters alone know the external systems and protocols. The chapter concludes by mapping these decisions into a contract map, where each neighbor gets one line describing direction, intent, mode, and contract ownership. That map clarifies which contracts WriteFlow owns and which it consumes, helps teams avoid mixing responsibilities, and provides a practical artifact that should be created before implementation and updated whenever contracts change.

The decisions for one interaction produce one contract-map entry. Here, the CMS’s request is inbound, synchronous because the CMS needs WriteFlow’s decision before continuing, and governed by a contract WriteFlow owns.
The decisions for one interaction produce one contract-map entry. Here, the CMS’s request is inbound, synchronous because the CMS needs WriteFlow’s decision before continuing, and governed by a contract WriteFlow owns.
Internal orchestration keeps the sequence inside one transaction. External orchestration spans services, so a coordinator holds the sequence durably and runs compensation when a later step fails.
Internal orchestration keeps the sequence inside one transaction. External orchestration spans services, so a coordinator holds the sequence durably and runs compensation when a later step fails.
Example of a potential external architecture as a contract map for WriteFlow. Every neighbor becomes one line that records a direction, a mode, and an owner. Draw your own the same way; the neighbors change, the four questions do not.
Example of a potential external architecture as a contract map for WriteFlow. Every neighbor becomes one line that records a direction, a mode, and an owner. Draw your own the same way; the neighbors change, the four questions do not.

Summary

  • Integration grows the edge of the hexagon, not its core. A new external system means a new adapter, not a new domain rule.
  • Direction is the first decision at any boundary. Inbound, the external system starts and is a driving actor; outbound, the hexagon starts, and the other system is a driven actor. Direction belongs to the interaction, not to the system.
  • Every message carries one of two intents. A request asks for work and expects an answer; a fact reports what happened and expects none. Either intent can travel in either direction.
  • There are three integration modes: a synchronous call, an event, and external orchestration. In a synchronous call, the caller waits; with an event, the publisher hands off a fact and continues; with external orchestration, a coordinator tracks the sequence across steps.
  • Internal orchestration is not one of the modes. A sequence that stays in one process and one transaction is the handler's own job. External orchestration is for a process that crosses services, outlives a request, or has to compensate a committed step, and it exists because distributed systems do not give atomicity across services for free.
  • Choose the mode from the interaction's consistency and time needs. A synchronous call when the next step needs the answer, an event when you only inform, a coordinator when the process must survive failure.
  • The same ownership rules hold in every mode. The domain decides what is allowed, the application layer decides what leaves, and the adapter is the only part that knows the other system. The correlation ID travels in an opaque envelope the core never opens.
  • Draw the contract map before you write the adapter. Separate the contracts you own from the ones you consume, and version the ones you own, because other teams depend on them.

FAQ

What is the first thing to decide when integrating WriteFlow with another system?The first decision is direction: determine which side starts the interaction. If the external system starts, the integration is inbound and the external system is a driving actor. If WriteFlow starts, the integration is outbound and the external system is a driven actor.
What is the difference between inbound and outbound integration?Inbound integration means the external system initiates the interaction and WriteFlow responds through an input adapter. Outbound integration means a WriteFlow use case initiates the interaction and an output adapter handles the external call, persistence, or event publication.
Can the same external system be both a driving actor and a driven actor?Yes. Direction is defined per interaction, not per system. The same external system may call WriteFlow in one case, making it a driving actor, and receive events or calls from WriteFlow in another, making it a driven actor.
How do you tell a request apart from a fact?A request asks another system to do something or provide information. A fact reports that something has already happened. The meaning of the message matters independently of how it is transported.
What are the three integration modes described in the chapter?The three modes are synchronous calls, event-driven integration, and external orchestration. They differ in who waits, who continues the work, and who owns recovery or sequencing across steps.
When should you use a synchronous call?Use a synchronous call when the caller needs the answer before it can continue. This creates time coupling: if the other system is slow or unavailable, the caller is delayed or blocked.
When should you use event-driven integration?Use event-driven integration when WriteFlow needs to publish a fact and let other systems react later. This favors independence and eventual consistency, but consumers must handle duplicates and possible out-of-order delivery.
When is external orchestration needed?External orchestration is needed when a process spans multiple systems, must survive failures, and needs durable sequencing, retries, or compensation. The coordinator owns the order of steps, while WriteFlow still owns what each step means and whether it is allowed.
Who owns the contract at the boundary?WriteFlow owns the contracts it publishes, such as its accepted commands, queries, and integration events. It consumes contracts owned by other systems through adapters, which isolate external format and protocol changes from the core.
What is a contract map and why is it useful?A contract map is a durable picture of the external architecture. It shows each neighbor and records the direction, request-or-fact intent, integration mode, and contract ownership for each interaction, helping teams understand and manage boundaries clearly.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Clean Applications with Hexagonal Architecture Clean Applications with Hexagonal Architecture ebook for free
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Clean Applications with Hexagonal Architecture Clean Applications with Hexagonal Architecture ebook for free