Designing Integration Jobs That Are Safe to Run Twice
Ali Saad · November 9, 2026 · 4 min read
A payroll export finishes sending its file, but the connection drops before the receiving system confirms delivery. The operator sees a failure and runs the job again. Did the first attempt fail, or did only its acknowledgement disappear? That uncertainty is where a simple retry becomes a business problem. For integrations, I find it useful to start with a different question: what happens if the same work arrives twice?
Define the operation before the retry
Idempotency means repeating the same logical operation does not create an additional business effect. It does not mean every execution follows an identical path or produces identical logs. An export may be attempted several times while the receiving system records it only once. The important boundary is the business operation, not the HTTP request or background process that happens to carry it.
Define that operation precisely. A customer, pay period, export type, and approved revision might identify one delivery. A fresh random identifier for every retry would identify attempts instead, losing the connection between them. Corrections need an explicit revision policy so that legitimate changes are distinguishable from accidental duplicates.
Record progress durably
A boolean named Sent rarely explains enough. Consider states such as prepared, delivery started, acknowledged, and reconciliation required. Store the operation identifier, attempt history, output fingerprint, and relevant timestamps somewhere that survives a process restart. The record should tell the next operator what is known and what remains uncertain.
Creating the record must also handle competing workers. A database uniqueness constraint can prevent two processes from registering the same logical operation independently. That alone cannot guarantee a remote side effect happens once: the receiver must participate in duplicate detection, or the integration needs another way to reconcile ambiguous delivery.
Treat timeouts as uncertainty
A timeout says the caller stopped waiting. It does not prove the receiver did nothing. Retrying a read is usually different from retrying a request that creates a payment instruction or imports employee hours. Classify failures by whether repeating the operation is safe, rather than retrying every exception with the same policy.
Where the receiver supports an idempotency key, reuse it across attempts and understand its scope and retention period. Otherwise, look for a delivery status query, an agreed file identifier, or a reconciliation process. Exponential backoff and bounded attempts help with temporary failures, but they cannot resolve duplicate business effects by themselves.
Make recovery visible to operators
An operator should see whether a retry resumes prepared work, regenerates a file, or sends an already produced artifact. Those actions can have different consequences if source data has changed. Preserve enough information to explain which input revision and configuration produced the original output before offering another delivery attempt.
A useful recovery screen also distinguishes confirmed failure from unknown outcome. For an uncertain delivery, checking the target may be safer than pressing Send again. Give support teams an operation identifier they can share with the receiving team, and keep sensitive payroll content out of routine diagnostic messages.
Test interruptions at the boundaries
Test a restart before delivery, a disconnect after delivery, two workers starting together, and an acknowledgement that arrives late. Verify the resulting business records, not only the number of successful method calls. Also test a genuine correction to ensure duplicate protection does not suppress an intended revised export.
These cases turn an abstract reliability goal into observable behavior. A job is recoverable when the team can explain the outcome of each interruption and identify the next safe action. A successful happy-path run provides much less evidence about that property.
Key takeaways
- ✓Identify logical operations separately from delivery attempts.
- ✓Persist progress and coordinate competing workers.
- ✓Treat a timeout as an uncertain outcome.
- ✓Test retries against the receiving system's business effects.
Conclusion
Safe retries come from an agreement about identity, progress, and recovery. They require more thought than wrapping a call in a retry policy, but that thought pays off when a job fails at the worst possible moment. The goal is for a repeated attempt to restore confidence without creating a second business problem.