Interface Types and subType Execution in Delegator Batch
Creating a separate Batch application for every integration looks simple at first, but execution history, restart logic, connection management, and Trace policy are duplicated with every application. Putting every operation into one oversized Step creates the opposite problem: workloads with different throughput and failure semantics run under the same policy.
Delegator Batch keeps a common Runtime while selecting an execution strategy from a type and subType pair. The type identifies the source-to-target connection shape, while the subType identifies the data mutation strategy and processing boundary. Building on The Basic Structure of Spring Batch Jobs and Steps, this article explains how that classification affects memory, transactions, restart, and watermarks.
Why Separate type from subType
Section titled “Why Separate type from subType”A type alone cannot select a complete execution policy. Two db2db jobs can have entirely different characteristics: replacing a small reference snapshot and incrementally upserting tens of millions of rows do not have the same memory or rollback boundary. A mutation label such as DELETE_INSERT alone is also insufficient because it does not say whether the source is an RDBMS, a search store, or an internal aggregation query.
| type | subType | Execution form | Suitable use |
|---|---|---|---|
db2db | DELETE_INSERT_COMMON | Tasklet | Replace a small complete snapshot |
db2db | UPSERT_COMMON | Tasklet | Merge a bounded set in one operation |
db2db | UPSERT_READER_WRITER | Chunk | Large or restartable incremental synchronization |
rest | REST_COMMON | Tasklet | Invoke a REST Transaction selected by Metadata |
search2db | DELETE_INSERT_COMMON | Tasklet | Store search results as a relational summary |
platformBatch | DELETE_INSERT_COMMON | Tasklet | Rebuild an internal aggregate table |
platformBatch | PURGE_COMMON | Tasklet | Delete data according to retention policy |
These values are not arbitrary class names. They form a restricted vocabulary that selects execution strategies registered in the Runtime. Allowing Configuration to inject class names or SQL strings directly would bypass validation and authorization boundaries.
interface: id: if-order-sync-001 type: db2db subType: UPSERT_READER_WRITER sourceRef: order-source targetRef: analytics-target chunkSize: 500 watermark: field: updatedAt overlapSeconds: 30sourceRef and targetRef are logical references resolved by the environment. Batch Metadata must not contain endpoints or credentials. Designing Metadata and Contracts for an Integration Platform covers the full Metadata structure and versioning model.
A Three-Step Skeleton Shared by Every Type
Section titled “A Three-Step Skeleton Shared by Every Type”Placing execution records around the business Step gives different subTypes one observable lifecycle.
insertLogSteprecords the execution ID, Interface ID, source reference time, and starting status.- The Interface Step runs the selected strategy and produces read/write/skip counts and the processed range.
updateLogSteprecords final status, end time, counts, and any watermark that can be committed.
A simple .next(updateLogStep) does not run the final Step when the Interface Step fails. If failure status must always be recorded, use a JobExecutionListener or a failure transition to guarantee finalization. Do not automatically place business data and execution history in one transaction, however. If business rollback also removes the failure record, operators cannot determine whether an execution happened.
Choosing Between Tasklet and Chunk
Section titled “Choosing Between Tasklet and Chunk”The distinction between Tasklet and Chunk is not a coding style choice. It defines commit and restart boundaries.

| Criterion | Tasklet bulk processing | ItemReader/Writer Chunk processing |
|---|---|---|
| Memory | May retain the complete result | Bounds memory through chunk size |
| Transaction | Whole operation or an explicit block | Usually commits per chunk |
| Restart | Commonly repeats the whole operation | Can resume after a checkpoint |
| Record count | Small with a known upper bound | Large or continuously growing |
| Error isolation | One row can fail the operation | Retry/skip policy can apply per item |
| Complexity | Lower | Requires Reader state and idempotency design |
Do not select a Tasklet only because a strategy is named UPSERT_COMMON. If source results exceed the memory limit or one transaction holds locks too long, use UPSERT_READER_WRITER. Conversely, a complex cursor checkpoint adds operational cost without benefit for a reference set of a few dozen rows.
Even in Chunk processing, a source and target in different databases do not acquire a distributed transaction automatically. A target chunk may commit before checkpoint persistence fails. The target write must therefore produce the same result when the same business key is replayed.
Consistency Models by subType
Section titled “Consistency Models by subType”DELETE_INSERT_COMMON
Section titled “DELETE_INSERT_COMMON”DELETE followed by INSERT makes it easy to align a target snapshot with its source. If the two statements run in separate transactions, however, a failure after DELETE can leave the target empty. A single transaction avoids that gap but can produce a large delete lock, transaction-log growth, and prolonged reader blocking.
For a small table, replace the data within one transaction. For a large table, load a staging table and switch to the validated snapshot. Before switching, compare source and staging counts and check required-key uniqueness. The first design question is not “Can DELETE be retried?” but “Which snapshot can readers observe after failure?”
UPSERT_COMMON
Section titled “UPSERT_COMMON”A bulk UPSERT is appropriate for merging a small incremental set in one transaction. It requires a stable business key. Duplicate keys within one input batch must be removed first or rejected explicitly. The Contract should also say whether multiple records for one key select the last record or fail validation.
UPSERT helps replay, but it is not inherently idempotent. An update clause such as updatedAt = now() or an accumulated total produces a different result every time the same input is replayed.
UPSERT_READER_WRITER
Section titled “UPSERT_READER_WRITER”Reader/Writer processing is appropriate when the data is large or partial restart is required. Offset pagination without a stable sort key can duplicate or omit rows while the source changes. Use a deterministic cursor such as (updatedAt, recordId) and persist its position in ExecutionContext.
A larger chunk is not always faster. It reduces round trips but increases heap use, lock duration, and rollback cost. Tune it using throughput together with p95 chunk duration, rollback count, and database lock wait.
REST_COMMON and Administrative Types
Section titled “REST_COMMON and Administrative Types”REST_COMMON is a Tasklet that invokes a registered REST Transaction once rather than implementing business logic in the Batch job. When a timeout occurs, the destination may already have processed the request. Automatic retry requires confirmation that the destination supports an idempotency key.
search2db and platformBatch distinguish the data source and operational owner. Storing a search summary requires recording the query period and bucket limit. An internal aggregate records its source data and computed period. Keeping PURGE_COMMON separate from aggregation allows its execution order, permission, and retention cutoff to be reviewed independently.
Advance a Watermark Only for a Successful Range
Section titled “Advance a Watermark Only for a Successful Range”Incremental extraction can use the previous completion time as the next starting point. Overwriting that value when the Job starts destroys the range needed for replay after failure. Keep in-progress and committed values separate.
committedWatermark = 2024-04-12T01:00:00ZcandidateUpperBound = 2024-04-12T02:00:00ZqueryRange = [committedWatermark - overlap, candidateUpperBound)The Job fixes candidateUpperBound at startup and promotes it to the new committedWatermark only after the Interface Step succeeds completely. Recomputing the current time for every query changes whether records arriving during execution are included.
A short overlap reduces boundary loss by intentionally reading some rows again, so the target needs UPSERT semantics and a deduplication key. When timestamp precision is low or multiple rows can share a timestamp, store a tuple such as (updatedAt, recordId) instead of a timestamp alone. If source modification times can move backward, a timestamp watermark cannot guarantee correctness; consider a change sequence or CDC.
Design for Failure, Restart, and Concurrent Runs
Section titled “Design for Failure, Restart, and Concurrent Runs”Failure handling differs by subType.
| Failure | Default handling | Reason |
|---|---|---|
| Invalid Metadata combination | Reject before startup | Retry cannot make it valid |
| Source connection timeout | Bounded retry | It can be transient |
| Target deadlock | Roll back the chunk and retry with backoff | It can relieve key contention |
| Schema or mapping error | Quarantine and fail | Repetition does not fix it |
| Lost REST response | Do not retry before checking idempotency | The destination side effect may be complete |
| Failure during purge | Restart with the same cutoff | Recomputing cutoff changes the deletion range |
Prevent concurrent execution for the same Interface and business date with a lock or unique Job parameters. Adding a timestamp as an identifying parameter on every run defeats duplicate-run prevention. Assume restart can encounter an already committed chunk, and design target keys and write statements accordingly.
Operational records should include interfaceId, type, subType, JobExecution ID, read/write/skip/retry counts, committed and candidate watermarks, and chunk duration. They should not include complete payloads or connection information.
Rules to Validate Before Deployment
Section titled “Rules to Validate Before Deployment”Even when Steps are created dynamically from Metadata, reject unsupported combinations before execution.
UPSERT_READER_WRITERrequireschunkSize, a stable sort key, and a checkpoint policy.DELETE_INSERT_COMMONrequires an expected maximum count and a rollback or staging strategy.- A
REST_COMMONretry policy must agree with the destination’s idempotency declaration. PURGE_COMMONrequires a retention basis, timezone, dry-run count, and maximum deletion count.- Resolve every reference through an allow-list and inject credentials from a secret store.
- Record Metadata version and checksum in execution history so the Job’s behavior can be reproduced.
Summary
Section titled “Summary”A type represents the connection shape, while a subType represents the mutation strategy and transaction boundary. Even under a common insertLogStep → Interface Step → updateLogStep skeleton, Tasklet and Chunk have different memory and restart properties and must be selected according to data volume and failure model.
DELETE-INSERT requires a snapshot-switching strategy, UPSERT requires stable business keys and idempotency, and Chunk requires checkpoints and tolerance for partial commits. A watermark must not be overwritten at startup; only a successfully processed range can be committed. These rules let one Batch Runtime execute many Interfaces without losing the consistency and operational meaning of each workload.