Skip to content

Designing Metadata and Contracts for an Integration Platform

Interactive Diagram

새 탭 ↗

Separating an Integration Runtime into Listener, Mapper, and Adapter does not make integrations flexible by itself. The Runtime still needs to know which Interface to select, which Transaction to execute, and which Channel and Mapper to use. When these choices are scattered through code, adding an integration requires a build and deployment, and tracking a Contract in production becomes difficult.

This article explains how to manage those choices as Metadata and how to manage exchanged data structures as Contracts. The examples are anonymized and are not tied to a particular organization or product.

Metadata describes how an integration is executed. A Contract describes the shape and meaning of the data exchanged by that integration.

CategoryQuestionTypical fields
Interface MetadataWhat entry point is this?interfaceId, route, protocol, lifecycle
Transaction MetadataWhat business operation is this?transactionId, direction, input/output Contract
Channel MetadataWhere and how is it sent?channelId, transport, target reference, policy
Mapper MetadataHow is the data transformed?mapperId, source/target schema, mapping version
ContractWhat data is allowed?field, type, required, format, semantic rule

An Interface is an integration unit identified from outside the platform. One Interface can contain multiple Transactions, while a Transaction defines the execution direction and input/output Contracts. A Channel represents the destination and transport characteristics, and a Mapper transforms between the canonical DataModel and an external Contract.

This separation is more than splitting database tables. It is a boundary between change reasons and deployment cycles. Changing only a timeout must not be mistaken for changing a payload schema, and adding an output field must not force code changes in every Listener.

The Runtime keeps execution Metadata separately from the received payload. The following is a conceptual model that is not tied to a particular serialization library.

{
"meta": {
"interfaceId": "IF-ORDER-001",
"interfaceVersion": 2,
"transactionId": "TX-ORDER-CREATE",
"transactionVersion": 1,
"channelId": "CH-ORDER-SERVICE",
"mapperId": "MAP-ORDER-CANONICAL",
"correlationId": "c-20240318-0001",
"messageId": "m-20240318-0001",
"hop": 1,
"txSeq": 0,
"occurredAt": "2024-03-18T09:30:00Z"
},
"payload": {
"orderId": "ORD-10042",
"totalAmount": 125000,
"currency": "KRW"
}
}

interfaceId, transactionId, channelId, and mapperId are Metadata used to find an execution plan. correlationId, messageId, hop, and txSeq are trace Metadata created or updated by the Runtime. payload is business data, so it is safer not to mix Runtime trace values into it.

An implementation can represent this conceptual model with an internal object such as DataModel. DataModel should provide the following information.

  • IDs identifying the Interface and Transaction
  • The current hop and Transaction sequence
  • Input and output data areas
  • References to the selected Mapper and Channel
  • Timestamp, error code, and error message
  • Immutable or explicit copy behavior for replay and reprocessing

hop and sequence are not merely log fields. They help determine which stage a message is in while it passes through multiple Adapters, and help prevent accidental re-entry or infinite loops. Runtime Metadata should not be exposed directly in an external Contract. Map only the correlation values required externally into a separate header or response field.

Relationships among Interface, Transaction, Channel, and Mapper

Section titled “Relationships among Interface, Transaction, Channel, and Mapper”

The following relationships can form a basic execution plan.

PlantUML Diagram

The Interface uses an entry condition such as a route or message key to find an active Transaction. A Transaction combines input and output Contracts, a Mapper, and a Channel into an execution unit. A Channel’s targetRef should be a safe reference rather than a literal endpoint or credential. Environment-specific secret stores and deployment policy should resolve that reference.

An Interface can contain fields like the following.

interface:
id: IF-ORDER-001
version: 2
status: ACTIVE
match:
method: POST
path: /integration/orders
transactions:
- id: TX-ORDER-CREATE
version: 1

Use explicit states such as DRAFT, ACTIVE, DEPRECATED, and RETIRED. The Runtime should not select Metadata whose state is not ACTIVE as an execution plan. Even when only a route changes, creating a new version and managing the transition window is safer than overwriting an active Interface.

A Transaction connects execution direction with Contracts.

transaction:
id: TX-ORDER-CREATE
version: 1
direction: REQUEST_RESPONSE
inputContract: order.request.v2
outputContract: order.result.v1
mapper: MAP-ORDER-CANONICAL@3
channel: CH-ORDER-SERVICE@2
retryProfile: transient-http-v1
responseMode: SYNC
retrySafe: false
idempotencyKeyField: orderId

retrySafe declares whether replaying this Transaction with the same input is safe. A resource-creating, non-idempotent request such as POST /integration/orders is retrySafe: false. When this value is false, statuses like 502 and 504 must be excluded from automatic retry, because the destination may already have processed the request. Not receiving a response is not the same as the request not being processed. If a retrySafe: false Transaction still needs retry, pass the value referenced by idempotencyKeyField to the destination as an idempotency key, and state in the Contract that the destination absorbs duplicates.

Treating REQUEST_RESPONSE and EVENT as the same thing confuses acknowledgement with a result response. Declaring response mode, idempotency requirements, and retry profile in Transaction Metadata lets Listener and Adapter share the same policy.

A Channel separates communication method from the logical destination reference.

channel:
id: CH-ORDER-SERVICE
version: 2
transport: HTTP
targetRef: order-service-primary
timeoutMs: 3000
retry:
maxAttempts: 3
backoff: EXPONENTIAL
retryableStatuses: [408, 429, 503]
retrySafeOnlyStatuses: [502, 504]
tlsProfile: platform-default

retryableStatuses should hold only statuses that clearly mean the destination did not process the request. Because 502 and 504 may mean the destination already processed it, keep them in retrySafeOnlyStatuses and apply them only when the Transaction is retrySafe: true or an idempotency key is passed. It is safer for Metadata validation to reject a deployment where a retrySafe: false Transaction declares unconditional retry on 502 or 504.

The example contains no real endpoint, IP, username, or password. The deployment environment resolves only targetRef; authentication data belongs in the secret-management system, not in a Contract or Metadata file. A separate Channel version allows a Transaction to move gradually to a new destination.

A Mapper is a set of input/output schemas and transformation rules, not merely a function name.

mapper:
id: MAP-ORDER-CANONICAL
version: 3
input: order.request.v2
output: order.canonical.v1
rules:
- from: orderNo
to: orderId
required: true
- from: amount.value
to: totalAmount
type: DECIMAL
scaleBy: currency
- from: amount.unit
to: currency
enum: [KRW, USD, JPY]
rejectUnknownFields: false

Fixing the amount scale to a constant discards the fact that minor units differ per currency. KRW and JPY have a minor unit of 0, but USD has 2. A Mapper pinned to scale: 0 turns 12.34 USD into 12 and silently corrupts the value. Declaring the scale as dependent on another field, as in scaleBy: currency, is safer, as is representing the amount as a minor-unit integer (amountMinorUnit) carried alongside the currency. Either way, currency-to-scale agreement belongs in Semantic validation.

Leaving rejectUnknownFields as false is a deliberate choice for forward compatibility. If an existing integration failed the moment the sender added a new field, deployment order would become tightly coupled. Accepting a field is not the same as forwarding it, however. An unknown field should be counted as a Metric and kept out of the canonical message, so that values the destination Contract never defined do not flow through unnoticed.

When an administration tool generates field lists and DataModel Metadata from Contract definitions, the Runtime can use explicit areas such as getInData() and getOutData(). The advantage of a generated DataModel is that access rules for IDs, hop, sequence, error state, and payload are fixed in one place. Directly editing generated output is unsafe because the next generation can overwrite it; change the source Metadata and generator input instead.

A Contract must be stricter than a field list

Section titled “A Contract must be stricter than a field list”

Validate a Contract in four layers.

  1. Transport validation: check method, content type, body size, and encoding.
  2. Structural validation: check JSON/XML shape, field type, required values, and array cardinality.
  3. Semantic validation: check currency units, date ranges, enums, and cross-field conditions.
  4. Business validation: check rules requiring an external lookup, such as business state or duplication.

For example, the following Contract describes more than the type of totalAmount.

contract:
name: order.request
version: 2
fields:
- name: orderId
type: STRING
required: true
maxLength: 40
pattern: '^[A-Z0-9-]+$'
- name: totalAmount
type: DECIMAL
required: true
min: 0
- name: currency
type: STRING
required: true
enum: [KRW, USD, JPY]
rules:
- "totalAmount >= 0"
- "currency == 'KRW' implies scale(totalAmount) == 0"
- "currency == 'JPY' implies scale(totalAmount) == 0"
- "currency == 'USD' implies scale(totalAmount) <= 2"

Per-currency scale rules belong to Semantic validation rather than Structural validation. That totalAmount is a DECIMAL is a question of shape, but judging USD 12.345 to be wrong depends on the meaning of another field, the currency.

A validation error should include field, rule, valueType, and message without recording the raw sensitive value. Structural validation failures normally should not be retried. A Channel connection timeout, in contrast, can be retried after considering side effects and the idempotency key.

Manage Schedule Metadata as operational state

Section titled “Manage Schedule Metadata as operational state”

Recurring execution settings can also live as Schedule Metadata in a database instead of being scattered through code or Kubernetes manifests. An administration screen should call a validation API rather than bypass it with direct table updates. On every tick, the Scheduler reads only active rows and translates them into dispatch requests for the Kubernetes Job-based Scheduler.

FieldRoleOperating rule
scheduleId, interfaceIdConnect a Schedule to the Interface it runsKeep immutable keys and reject duplicates
cronExpression, timeZoneDefine execution timeParse before storing and require an explicit timezone
enabled or statusPermit executionfalse or INACTIVE blocks new dispatches only
revision, updatedAt, updatedByDetect update conflicts and provide auditKeep optimistic locking and change history
runtimeProfileReference an approved image, resource, and argument profileStore neither raw secrets nor arbitrary commands

An enable/disable toggle is simple only when its semantics are explicit. Disabling a row does not cancel an already-running Job; it prevents dispatch from the next scheduled slot onward. Immediate termination requires a separate cancellation permission and procedure. Changes to Cron, timezone, or profile in the screen must pass server-side validation first, and the Scheduler should record the row revision with the execution snapshot so operators can later explain which settings a run used.

The boundary between configuration and Runtime

Section titled “The boundary between configuration and Runtime”

The most important question in a Metadata-driven design is what can safely become configuration.

Put in Configuration/MetadataKeep in Runtime code and common policy
Interface route and statusEnvelope creation and correlationId propagation
Transaction input/output Contract referencesSchema-validator execution order
Channel and Mapper selectionError classification and quarantine handling
Timeout and retry-profile selectionBackoff, retry budget, and circuit-breaker execution
Field mapping and enumsSecret lookup, authorization, and log masking
Response mode and versionHop increment, sequence management, and metric format

Configuration declares “what to select,” while the Runtime guarantees “how to execute that selection safely.” Accepting an arbitrary class name from configuration and invoking it through reflection can deploy unvalidated behavior. Mappers and Adapters should be selected only through an allow-list of registered mapperId, channelType, and policyId values.

Even if a timeout is configurable, negative timeouts, excessive retry counts, and unsupported transport combinations must be rejected during Configuration validation. Instead of silently applying defaults after loading invalid Metadata, fail fast during startup or reload so behavior remains predictable.

Metadata should be validated and deployed with the same discipline as application code.

  1. Validate the schema itself with JSON Schema or an equivalent validator.
  2. Verify every reference: transaction.channel, transaction.mapper, and Contract versions are typical targets.
  3. Detect conflicts among Interface routes and versions.
  4. Check type compatibility between Mapper source and target fields.
  5. Validate retry-profile/transport and response-mode/direction combinations.
  6. Run validation and mapping with anonymized sample payloads.
  7. Create an immutable bundle and record its checksum and version.
  8. Apply it through a canary or staged reload, then verify the active bundle.

If runtime reload is supported, record which bundle each in-flight message used. Without a metadataVersion or bundle ID in traces and audit events, it is impossible to explain why the same payload produced a different result later.

A Contract version is a compatibility policy, not merely an incrementing number.

  • Backward compatible: add an optional field that existing consumers can ignore, or widen the representation while preserving existing values.
  • Breaking change: adding a required field, changing a field type, removing an enum value, changing meaning, or deleting a field requires a separate major version.
  • Mapper version: increment the Mapper version when transformation rules between the same Contracts change. It does not always have to equal the Contract version.
  • Channel version: increment the Channel version when the endpoint, authentication profile, timeout policy, or other transport boundary changes.

A compatibility matrix makes the transition plan easier to verify.

Producer ContractConsumer ContractMapperPolicy
order.request.v2canonical v1MAP-ORDER-CANONICAL@3Current default path
order.request.v1canonical v1MAP-ORDER-CANONICAL@2Allowed until sunset
order.request.v3canonical v1MAP-ORDER-CANONICAL@4Canary target

Supporting old Contracts indefinitely causes Metadata and test combinations to explode. Record introducedAt, deprecatedAt, and sunsetAt, then remove a version only after confirming that its call volume is zero. When deploying a new version, define producer/consumer transition order, the previous bundle for rollback, and whether data can be replayed.

Failure model and operational observability

Section titled “Failure model and operational observability”

Metadata errors and external communication errors are different categories.

Failure pointExampleRetry
Metadata loadInvalid reference, duplicate routeNo; reject the bundle
Contract validationMissing required field, type errorNo; record a Contract error
MapperUnconvertible enum, overflowNo; quarantine the message
ChannelTimeout, rate limit, transient 5xxApply policy
Business responseDuplicate order, state conflictFollow business rules

Record interfaceId, transactionId, channelId, mapperId, metadataVersion, correlationId, hop, and result code as structured events for every execution. Do not copy the complete payload into logs; apply field-level masking and retention periods. This allows incident investigation without unnecessarily spreading personal data or authentication information contained in a Contract.

To minimize code changes, use the following sequence.

  1. Define the Interface and route match.
  2. Register input/output Contracts and schema versions.
  3. Define the canonical DataModel and field mapping.
  4. Connect the Mapper, Channel, and response mode in the Transaction.
  5. Run static reference validation and a sample mapping test.
  6. Run a Listener, Mapper, Adapter integration test with anonymized payloads.
  7. Deploy to a canary Channel and inspect trace Metadata.
  8. Switch to the active version after stable results and schedule the previous version’s sunset.

In the normal case, neither the Listener nor Adapter code changes. Add an explicit extension only for behavior the common Runtime cannot express, such as a new transport type, special encryption, or complex streaming semantics.

Metadata is the execution plan used to select and compose an integration. A Contract is the boundary of data that the execution can exchange.

  • An Interface identifies an entry point and exposes Transactions.
  • A Transaction combines Contracts, Mapper, Channel, and execution policy.
  • A Channel represents a destination and transport policy through references.
  • A Mapper preserves meaning between external Contracts and the canonical DataModel.
  • A DataModel separates business payload from Runtime Metadata.
  • Configuration declares selections; the Runtime guarantees validation, tracing, and safe execution.
  • Recording the version and bundle ID in traces makes changes explainable.

With this model, a new integration is first expressed as a change to Metadata and Contracts. Code deployment and data-contract changes can then be separated, while validation, versioning, and rollback become consistent operational practices.