Designing Metadata and Contracts for an Integration Platform
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.
Separate Metadata from Contracts
Section titled “Separate Metadata from Contracts”Metadata describes how an integration is executed. A Contract describes the shape and meaning of the data exchanged by that integration.
| Category | Question | Typical fields |
|---|---|---|
| Interface Metadata | What entry point is this? | interfaceId, route, protocol, lifecycle |
| Transaction Metadata | What business operation is this? | transactionId, direction, input/output Contract |
| Channel Metadata | Where and how is it sent? | channelId, transport, target reference, policy |
| Mapper Metadata | How is the data transformed? | mapperId, source/target schema, mapping version |
| Contract | What 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.
A basic model for execution Metadata
Section titled “A basic model for execution Metadata”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
hopand 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.
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.
Interface Metadata
Section titled “Interface Metadata”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: 1Use 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.
Transaction Metadata
Section titled “Transaction Metadata”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: orderIdretrySafe 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.
Channel Metadata
Section titled “Channel Metadata”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-defaultretryableStatuses 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.
Mapper Metadata and generated DataModel
Section titled “Mapper Metadata and generated DataModel”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: falseFixing 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.
- Transport validation: check method, content type, body size, and encoding.
- Structural validation: check JSON/XML shape, field type, required values, and array cardinality.
- Semantic validation: check currency units, date ranges, enums, and cross-field conditions.
- 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.
| Field | Role | Operating rule |
|---|---|---|
scheduleId, interfaceId | Connect a Schedule to the Interface it runs | Keep immutable keys and reject duplicates |
cronExpression, timeZone | Define execution time | Parse before storing and require an explicit timezone |
enabled or status | Permit execution | false or INACTIVE blocks new dispatches only |
revision, updatedAt, updatedBy | Detect update conflicts and provide audit | Keep optimistic locking and change history |
runtimeProfile | Reference an approved image, resource, and argument profile | Store 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/Metadata | Keep in Runtime code and common policy |
|---|---|
| Interface route and status | Envelope creation and correlationId propagation |
| Transaction input/output Contract references | Schema-validator execution order |
| Channel and Mapper selection | Error classification and quarantine handling |
| Timeout and retry-profile selection | Backoff, retry budget, and circuit-breaker execution |
| Field mapping and enums | Secret lookup, authorization, and log masking |
| Response mode and version | Hop 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 validation and deployment order
Section titled “Metadata validation and deployment order”Metadata should be validated and deployed with the same discipline as application code.
- Validate the schema itself with JSON Schema or an equivalent validator.
- Verify every reference:
transaction.channel,transaction.mapper, and Contract versions are typical targets. - Detect conflicts among Interface routes and versions.
- Check type compatibility between Mapper source and target fields.
- Validate retry-profile/transport and response-mode/direction combinations.
- Run validation and mapping with anonymized sample payloads.
- Create an immutable bundle and record its checksum and version.
- 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.
Contract versioning rules
Section titled “Contract versioning rules”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 Contract | Consumer Contract | Mapper | Policy |
|---|---|---|---|
order.request.v2 | canonical v1 | MAP-ORDER-CANONICAL@3 | Current default path |
order.request.v1 | canonical v1 | MAP-ORDER-CANONICAL@2 | Allowed until sunset |
order.request.v3 | canonical v1 | MAP-ORDER-CANONICAL@4 | Canary 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 point | Example | Retry |
|---|---|---|
| Metadata load | Invalid reference, duplicate route | No; reject the bundle |
| Contract validation | Missing required field, type error | No; record a Contract error |
| Mapper | Unconvertible enum, overflow | No; quarantine the message |
| Channel | Timeout, rate limit, transient 5xx | Apply policy |
| Business response | Duplicate order, state conflict | Follow 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.
Adding a new integration
Section titled “Adding a new integration”To minimize code changes, use the following sequence.
- Define the Interface and route match.
- Register input/output Contracts and schema versions.
- Define the canonical DataModel and field mapping.
- Connect the Mapper, Channel, and response mode in the Transaction.
- Run static reference validation and a sample mapping test.
- Run a Listener, Mapper, Adapter integration test with anonymized payloads.
- Deploy to a canary Channel and inspect trace Metadata.
- 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.
Summary
Section titled “Summary”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.