Skip to content

Why an Integration Runtime Separates Listener, Mapper, and Adapter

Interactive Diagram

새 탭 ↗

Enterprise integration initially looks like a simple task: call an API and return its response. As the number of integrations grows, protocols, data contracts, retries, response waiting, trace context, and failure handling become entangled. Copying transformation and outbound-call code into every REST endpoint quickly raises both change cost and operational risk.

This article describes a runtime structure that separates Listener, Mapper, and Adapter so that different communication styles can share one execution model. It is not tied to a particular product or organization; the pattern applies to HTTP, messaging, file, and database integrations.

Even when their source and destination differ, integration requests repeat the same steps.

  1. Receive a request or event.
  2. Identify the interface being invoked.
  3. Validate the input contract and normalize it into an internal message model.
  4. Select the destination and transport method.
  5. Communicate with the external system.
  6. Connect a response or result back to the caller.
  7. Record the same trace identity and failure information across the entire path.

When every application implements these steps separately, three problems appear.

  • Protocol coupling: HTTP handling code contains external API calls, JSON transformation, and retry policy at the same time.
  • Contract duplication: Multiple services interpret the same structure differently, causing field and error rules to drift.
  • Broken tracing: Receive logs and outbound-call logs use different identities, making it impossible to follow one request end to end.

The purpose of a runtime is not to make every integration use identical code. It is to leave variable points as configuration and extension points while standardizing repeated execution rules.

A Listener turns external input into internal execution

Section titled “A Listener turns external input into internal execution”

A Listener is the boundary where an external system enters the platform. It can be an HTTP endpoint, message consumer, file watcher, or database polling worker.

Its responsibility should be limited to the following.

  • Transport-level authentication and request size limits
  • Interface identification from receive context such as path, headers, message keys, or file names
  • Safe recording of the raw payload and masking of sensitive data
  • Transport validation of method, content type, size, and encoding; pass receive context and correlationId (the Input Mapper owns payload-contract validation and canonical message creation)
  • A response channel for synchronous requests or acknowledgement handling for asynchronous requests

A Listener must not know a target system URL, authentication method, or field-level transformation rule. Once those details enter the Listener, changing a receive method forces changes across the whole integration flow.

A Mapper preserves meaning between contracts

Section titled “A Mapper preserves meaning between contracts”

A Mapper handles the difference between a source contract and a target contract. It does more than rename JSON fields. It preserves meaning in date formats, currency units, code systems, repeating structures, and null rules.

It is useful to think about a Mapper in two stages.

  • Input normalization: convert an external contract into the platform canonical message.
  • Output specialization: convert the canonical message into a destination contract.
  • Result transformation: validate the destination response contract and transform it into the caller response contract. The Listener sends the mapped response but does not map its fields.

A canonical message must separate business payload from execution metadata. For example, correlationId, interfaceId, hop, and occurredAt are runtime-owned metadata, not business data. Mixing the two means that a destination-contract change can also break the tracing model.

An Adapter encapsulates destination communication

Section titled “An Adapter encapsulates destination communication”

An Adapter is the boundary toward a target system. HTTP clients, SOAP clients, message producers, SFTP clients, and database writers all belong here.

An Adapter is responsible for the following.

  • Selecting a destination channel and managing connections
  • Communication policy such as timeouts, retries, and circuit breakers
  • Destination-specific authentication and credential references
  • Sending payloads that match the target request and response contracts
  • Forwarding the response/error on the result path (the Result Mapper owns conversion into the caller response contract)
  • Converting external failures into a platform-wide error model

The important constraint is that an Adapter does not reconstruct the whole business flow. The Adapter focuses on “send this message to this target with this policy.” Mappers own data transformation, while an orchestration layer owns flow control.

The execution flow of a synchronous request

Section titled “The execution flow of a synchronous request”

Even a synchronous HTTP request can be split into an asynchronous internal message flow. That keeps a receive server from being polluted by destination-communication details when an external call takes time.

PlantUML Diagram

The caller knows only HTTP, and the target system does not know that it sits behind an HTTP Adapter. The Message Bus does not have to be a particular product either. A durable queue, event stream, or in-process dispatcher can be selected according to the platform’s reliability and throughput requirements.

Response waiting, timeout, and late-result decision rules (proposed design)

Section titled “Response waiting, timeout, and late-result decision rules (proposed design)”

The diagram above shows the intended happy path, not evidence that timeout handling has been verified in operation. A synchronous waiter needs a coordinator that looks up a pending request by correlationId and execution identity, with an atomically managed deadline and completion state. The Listener owns transport delivery to the caller; the Result Mapper owns the result-contract boundary.

  1. First result before the deadline: the Result Mapper validates and transforms the target result. The coordinator completes the pending state only once, then the Listener returns it to the caller.
  2. Deadline reached: the coordinator transitions the pending state to timed out, and the Listener returns the defined timeout response. An Adapter communication timeout and a caller response-wait deadline are distinct. The destination may already have processed the request, so timeout is neither proof of failure nor an unconditional retry signal.
  3. Result after timeout or duplicate result: when the same execution identity is already timed out/completed, do not write a second HTTP response. Use result identity and state transitions for duplicate detection and retain a payload-safe observation for investigation. Reprocessing requires a separate reconciliation procedure; do not automatically resend side-effecting requests without destination-side idempotency guarantees.

With a durable bus and multiple Listener instances, pending state must not live only in instance memory; validate a shared, recoverable store and atomic transitions. This article presents no implementation, restart recovery, or race-test evidence for those rules, so they must not be read as an implemented or exactly-once guarantee.

Why the runtime must own correlation IDs and hops

Section titled “Why the runtime must own correlation IDs and hops”

When a request passes through Listener → Mapper → Adapter → Listener, it produces multiple logs and potentially multiple retries. A single request ID may not be enough.

  • correlationId: groups the complete business request or message exchange.
  • messageId: identifies an individual delivery attempt and can change on retry.
  • hop: records the logical stage that the current message passed through.
  • attempt: indicates the transmission count for the same channel.

These values belong in a runtime envelope rather than the external payload. This preserves end-to-end tracing without changing an external contract.

{
"meta": {
"correlationId": "c-01HV...",
"messageId": "m-01HV...",
"interfaceId": "order-created-v1",
"hop": 2,
"attempt": 1,
"occurredAt": "2024-03-18T09:30:00Z"
},
"payload": {
"orderId": "ORD-10042",
"totalAmount": 125000,
"currency": "KRW"
}
}

The identifiers and payload in this example are fictional. In a production environment, customer data, authentication headers, and raw messages must not be copied directly into logs or message envelopes.

Asynchronous and polling workloads use the same role model

Section titled “Asynchronous and polling workloads use the same role model”

A Listener does not always have a server role. A worker that reads a file or polls a database performs “receiving” from the business perspective, but is a client from the communication perspective. Conversely, an external webhook caller makes a Listener a server.

Component names must therefore not be equated with transport roles.

Business perspectiveExampleCommunication roleRuntime role
Receive an external requestREST webhookServerListener
Collect a fileSFTP pollingClientListener
Query data and publish itDatabase pollingClientListener
Call an external APIREST/SOAP callClientAdapter
Deliver a fileSFTP uploadClientAdapter
Deliver an internal eventMessage publishProducerAdapter

Making this distinction explicit lets polling and webhooks use the same processing model without the mistaken assumption that every Listener must be a server.

Recording errors only as success or failure makes retry decisions and ownership unclear. Classifying failures by role boundary creates consistent operating rules.

BoundaryTypical failureDefault response
ListenerAuthentication failure, unsupported content type, payload too largeReject immediately and return a 4xx response
Input MapperSchema validation failure, missing required field, unsupported codeDo not retry; record as a contract error
AdapterConnection timeout, transient 5xx, rate limitCheck side effects and idempotency before policy-based backoff retry
Target contractValidation error, business-rule violationDo not retry; normalize as a destination error
Result MapperResponse contract mismatchSend to a quarantine queue and investigate contract change

A retry decision should not be based merely on whether an exception was thrown. It should be based on whether sending the same input again could produce a different outcome. When an outbound request can create a side effect such as an order, payment, or registration, the Adapter must also use an idempotency key or a destination-side duplicate-prevention mechanism.

What belongs in configuration and what remains in code

Section titled “What belongs in configuration and what remains in code”

Turning everything into configuration creates a different kind of complexity. Separate interface-specific information from behavior that the platform must guarantee.

Manage as configurationGuarantee in code or common policy
Interface ID and route-match ruleCanonical envelope structure
Input/output schema referenceCorrelation ID creation and propagation
Mapper selectionError classification model
Channel and target referenceLog-masking rules
Timeout/retry profile selectionRetry executor and backoff algorithm
Response modeMetric, trace, and audit-event format

The next article will model the left side of this table as Interface, Transaction, Channel, and Mapper metadata, then show how that model reduces the code-change surface when a new integration is added.

Separating Listener, Mapper, and Adapter is not an attempt to add layers for their own sake. It creates independent boundaries for three different causes of change: receive method, data contract, and destination communication.

  • A Listener turns external input into safe internal execution.
  • A Mapper preserves meaning between contracts.
  • An Adapter encapsulates destination communication and its failures.
  • Correlation IDs, hops, and the error model are cross-cutting runtime responsibilities.

Once these boundaries are in place, HTTP, messaging, file, and database integrations can be traced and extended through the same operating model.