Scrivio Interview library
DesignAdvanced6 min read · updated 12 November 2026

Several teams run Spring Integration applications for file transfers and partner integrations, and incidents show silent failures and duplicate processing. What operating standards would you set for these applications?

We would set a small number of standards that every Spring Integration application must meet: every flow has an error channel that logs, counts and alerts, with failed messages moved to a quarantine store; persistent metadata stores and idempotent receivers so restarts never reprocess files or messages; Micrometer metrics for messages in, out and failed per flow; a documented owner, partner contact and recovery steps for each flow; and integration tests in CI against realistic stub endpoints. Silent failures and duplicates are both symptoms of flows that were built for the happy path, and these standards close those gaps.

Background to this question

File transfers and partner integrations rarely get attention until a partner calls to ask why yesterday's orders never arrived, or why they were charged twice. By then the logs have rotated and the team that wrote the flow has moved on. A senior engineer asked to stop this is expected to set standards that are specific, cheap to apply and checkable, not a long policy document. In this answer, we will look at why these flows fail silently and duplicate work, then go through each standard with the reason for it and how to apply it in Spring Integration.

1Why These Flows Fail Silently and Duplicate Work

Spring Integration makes it easy to build a flow that works on the first day. The defaults, however, favour simplicity over operations. When an asynchronous step fails, the exception goes to the global errorChannel, which just logs it, so the failure is one log line among millions. In-memory file filters forget what they processed when the application restarts, so every file still in the directory is processed again. Nothing counts how many messages a flow handled, so a flow that has quietly stopped looks the same as a quiet day.

Each incident the teams reported is one of these defaults meeting production. The standards below replace each default with an operational choice.

Incident causes and the standard that answers each
IncidentUsual causeStandard
Failure nobody noticederror only logged by default errorChannelown error channel, counter, alert
Bad message lostnowhere to put itquarantine store
Files reprocessed after restartin-memory accept-once filterpersistent metadata store
Message applied twiceredelivery with no duplicate checkidempotent receiver
Flow stopped, nobody knewno per-flow metricsMicrometer metrics, rate alerts
Slow recoveryno owner or runbookflow documentation

2Standard 1: An Error Channel, Counted and Alerted, With Quarantine

Every flow defines its own error channel instead of relying on the global one. Pollers and asynchronous channels send failures there as ErrorMessages, which carry the failed message and the exception. The error flow does three things: it logs the flow name, message id and cause in a structured way; it increments a counter tagged with the flow name, which drives an alert; and it moves the failed message or file to a quarantine store, a database table, a queue or a directory, where it can be inspected and replayed.

Java
@Bean
IntegrationFlow partnerErrors(MeterRegistry meters, QuarantineStore quarantine) {
return IntegrationFlow.from("partnerErrors")
.handle(MessagingException.class, (ex, headers) -> { // payload of the ErrorMessage
var failed = ex.getFailedMessage();
log.error("flow=partner-orders id={} cause={}", failed.getHeaders().getId(), ex.getMessage());
meters.counter("integration.flow.failed", "flow", "partner-orders").increment();
quarantine.save("partner-orders", failed, ex); // kept for inspection and replay
return null; // end of the error flow
})
.get();
}

The quarantine is what turns a silent failure into a visible task. Its size is itself a metric, and an item older than a day is an alert.

3Standard 2: Persistent Metadata Stores and Idempotent Receivers

Any file or message source that remembers what it has processed must remember it durably. For file adapters, that means persistent accept-once filters backed by a JdbcMetadataStore or Redis, shared by every instance, never the in-memory default. For messages that can be redelivered, such as from JMS or Kafka, a flow that changes state must recognise duplicates.

Spring Integration supports this with an idempotent receiver: an interceptor in front of an endpoint that checks a key, such as a business id from the payload, against a metadata store, and either discards duplicates or marks them with a header so the flow can decide. The key must be a business id that stays the same across redeliveries and resends, not a generated message id.

Java
@Bean
IdempotentReceiverInterceptor dedupe(ConcurrentMetadataStore store) {
var selector = new MetadataStoreSelector(m -> ((PartnerOrder) m.getPayload()).orderNumber(), store);
var interceptor = new IdempotentReceiverInterceptor(selector);
interceptor.setDiscardChannelName("duplicates"); // counted, not processed again
return interceptor;
}

4Standard 3: Metrics for Every Flow

Spring Integration registers Micrometer meters for channels and handlers when a MeterRegistry is present, such as timers for message sends with success and failure tags. We make sure each flow's components have meaningful names, so the meters say partner-orders rather than an auto-generated bean name, and we add counters at the flow's edges: messages in, messages out, messages failed, messages quarantined.

Dashboards then show each flow's rates side by side, and alerts fire on what matters: failures above zero for critical flows, and, just as important, input that stops when it should not. A partner file that normally arrives every hour and has not arrived for three hours is an incident, even though nothing failed.

5Standards 4 and 5: Documentation and Realistic Tests

Each flow has a short page kept next to its code: the business purpose, the owning team, the partner and their contact, the schedule and volumes to expect, and recovery steps for the common failures, such as how to replay a quarantined file or reset a file's entry in the metadata store. When a flow fails at night, the on-call engineer should not need to read the code to know whom to call.

Every flow has integration tests in CI that run against realistic stubs: an embedded SFTP server with real sample files, including a malformed one, WireMock for HTTP partners, and Testcontainers for brokers. The tests cover the failure paths the standards promise, such as a malformed file landing in quarantine, a restart not reprocessing a file, and a duplicate message being discarded.

Step throughChecking an existing flow against the standards
  1. Own error channel with counter and alert?
  2. Failed messages quarantined?
  3. Persistent, shared metadata store?
  4. Idempotent where redelivery is possible?
  5. Metrics and an inactivity alert?
  6. Owner page and CI tests with stubs?

6 steps in order. Play them, or step through them one at a time.

We roll the standards out with a checklist reviewed for each existing flow, starting with the flows behind recent incidents, and with a starter library that gives new flows the error channel, metrics and persistent stores by default, so following the standard is the easiest path.

6Follow-up questions

Isn't a central error channel for all flows simpler?

It is simpler to set up but harder to operate, because every failure lands in one place without context and with one shared alert. A per-flow error channel lets each flow be counted, alerted and quarantined separately, and lets its owner be paged. The starter library can make the per-flow channel just as easy to create.

How long should metadata store entries be kept?

As long as a file or message could reappear: for files, while they can still be on the remote server; for messages, longer than the broker's redelivery window. Entries for files moved to a processed directory can be expired after a retention period, which keeps the table small.

How do you get teams to apply standards to old flows?

Prioritise by incident history and business impact, give each team a checklist and the starter library, and track progress openly. Flows behind recent incidents go first, because their owners already feel the cost.

7Conclusion

In this answer, we set operating standards for Spring Integration flows: a per-flow error channel that logs, counts and alerts with a quarantine store for failed messages, persistent metadata stores and idempotent receivers to stop reprocessing, Micrometer metrics for messages in, out and failed with inactivity alerts, a documented owner, partner contact and recovery steps for each flow, and CI integration tests against realistic stubs.

What to say in the interviewAbout 90 seconds aloud

Open with

The incidents tell me the flows were built for the happy path on Spring Integration's defaults, so I'd set a few specific standards and make them easy to follow.

Then, if they want more

First, every flow has its own error channel. It logs the flow name, message id and cause, increments a counter tagged with the flow that drives an alert, and moves the failed message or file into a quarantine store where it can be inspected and replayed. That ends silent failures.

Second, anything that remembers what it processed must do it durably: persistent accept-once filters on a JDBC or Redis metadata store shared by all instances, and idempotent receivers keyed on a business id wherever messages can be redelivered. That ends the duplicates.

Third, per-flow Micrometer metrics, messages in, out and failed, with alerts on failures and on inactivity, because a partner file that stops arriving is also an incident. Fourth, each flow has a short owner page: purpose, team, partner contact, expected schedule and recovery steps.

Fifth, CI integration tests against realistic stubs, like an embedded SFTP server with a malformed file, WireMock and Testcontainers, covering the failure paths. I'd roll it out with a checklist, starting from the flows behind recent incidents, and a starter library so new flows get all this by default.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring Cloud Stream reference
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Several teams run Spring Integration applications for file transfers and partner...": https://scrivio-interview-library.netlify.app/spring-boot/spring-cloud-stream/34fefb5953/