Software engineering
System integrations: handling failures without losing data
Learn how to handle duplicates, retries and partial failures across sales, payments and ERP integrations while keeping pending operations recoverable.
A customer completes a purchase. The payment service confirms the charge, but its response never reaches the sales system. The order remains pending and has not yet been sent to the company's enterprise resource planning system, or ERP.
The team must decide what to do. Repeating the charge could create a duplicate. Treating the purchase as cancelled could leave a customer charged without receiving their order. Sending the order to the ERP without confirmation could also introduce an inconsistency.
In this hypothetical scenario, integrations must handle situations where some work has happened and some remains uncertain. Reliability depends on recognizing those states, recording progress and allowing controlled recovery.
A workflow that keeps pending operations visible
An integration can separate payment confirmation from delivery of the order to the ERP. Its states and confirmation mechanisms must follow the contracts of the connected systems.
A lost response must be investigated using the original reference. The team only proceeds with delivery to the ERP once it has a valid payment confirmation. That confirmation may come from a status query or an authenticated notification, depending on the API.
A timeout does not confirm that an operation failed
When a call exceeds its timeout, the calling system knows it did not receive a response within the allotted time. That alone does not reveal whether the other system carried out the request.
In the purchase example, the charge might have completed before the connection dropped. This differs from an explicit rejection stating that the payment was not made.
Keep that distinction in application state. An operation can be confirmed, rejected or awaiting confirmation. Customer support and automations should consult that state instead of interpreting every communication failure as a cancellation.
To resolve uncertainty, use the mechanisms supported by the integration, such as reference-based queries and outcome notifications. Check which guarantees exist and which information connects the response to the original operation.
Retries must preserve the original intent
Idempotency allows an operation to be repeated without adding its business effect again. An integration contract can support this through a key identifying that particular business intent.
Retries of the same charge should reuse its original key. A genuinely new charge needs a different identifier. Define how the API handles a repeated key with different parameters and how long duplicate requests remain recognizable.
The Amazon Builders' Library discusses these concerns in idempotent API design.
In the local implementation, detecting a duplicate and recording its effect also requires protection against concurrent calls. When both writes belong to the same database, a transaction and appropriate constraints can keep them consistent.
An external call sits outside that local transaction. It requires the recipient's supported mechanism and explicit handling of uncertain outcomes. Adding an identifier to a request does not automatically make an API idempotent.
Bound retries and space them out
Some failures are temporary: a brief outage, a lost connection or a rate limit. Others require corrections to data, permissions or a business rule.
Resending the same invalid information indefinitely consumes resources without resolving the cause. Classify outcomes according to each integration's contract and define which ones justify another attempt.
Use increasing intervals, an attempt or time limit, and a small random variation in the delay, known as jitter. This helps avoid many clients calling the service again at the same moment.
The guidance on timeouts, retries and backoff also explains how retrying can worsen overload. Account for retries already performed by libraries and other components so they do not multiply unnoticed.
When the limit is reached, keep the operation recorded for investigation or recovery. Ending automatic attempts should not erase the pending work.
Queues provide a place to wait, but need clear rules
If payment is confirmed while the ERP is unavailable, a queue can separate accepting the purchase from sending it to the management system. The order remains recorded and waits for processing.
This changes what completion means for the customer: payment received and order recorded can be different milestones from completion of the entire integration.
Configure persistence, retention and acknowledgements for the technology in use. The RabbitMQ documentation distinguishes publisher confirms from consumer acknowledgements: knowing that the broker received a message does not mean the ERP completed its work.
The consumer should acknowledge the message after completing and persisting the corresponding processing, or after safely transferring responsibility to another durable stage. If it fails before acknowledging, the message may be delivered again.
Processing must therefore handle duplicates too. If update order matters, define how an old message is prevented from overwriting newer state.
Close the gap between saving and publishing
A less visible failure happens when the system saves the purchase in the database but stops before publishing the message that should send it to the ERP. The order exists, but no component has taken responsibility for the next step.
One approach is a transactional outbox. The application saves the business change and an event record in the same database transaction. A separate process publishes events that are still pending.
The transactional outbox pattern addresses this combination of persistence and notification. It does not create a single transaction across sales, payment and ERP systems.
The publisher may fail after sending an event but before recording that it was sent. The message can then be published again. Recipients must recognize repeated operations, and the team needs visibility into events still awaiting publication.
Recovery depends on business rules
An ERP failure does not necessarily mean a confirmed payment should be reversed. Keeping the order pending and retrying the integration later might be the correct procedure.
In another situation, the company may need to cancel the operation and request a refund. This is a compensating action: it addresses an effect already produced according to business rules, without assuming the exact previous state can be restored.
Microsoft's compensating transaction pattern explains that compensation can fail as well and must record its progress.
Define who can approve that path, which conditions permit it and how completion will be checked. A pending refund needs its own follow-up; it should not disappear because an order was marked cancelled.
Reconcile and monitor unfinished work
Not every inconsistency appears as an error when it happens. Periodically compare operation references and states across the systems.
For the purchase example, reconciliation could look for confirmed payments without a corresponding order, paid orders still missing from the ERP, and cancellations whose compensation has not completed.
Those discrepancies should trigger investigation. Querying the outcome again or sending the case for review may be necessary before repeating any action.
Track the age of pending work, failure volume and cases that are no longer retried automatically. Messages placed in a failure queue need an owner and a reprocessing procedure.
Test lost responses, duplicate messages and interruptions after writes. Check the resulting data and effects: a call returning without an error does not, by itself, prove that the purchase was integrated correctly.
A checklist before going live
Alongside the successful path, test situations where a stage becomes uncertain:
- The response is lost after a charge. Does the system retain its reference and query the outcome without creating another charge?
- The same notification arrives twice. Is state updated without repeating the business effect?
- The process stops after saving an order. Does the pending event remain available for publication?
- The consumer stops after sending to the ERP. Does reprocessing recognize what has already been integrated?
- An old update arrives late. Is it identified before overwriting current state?
- An attempt needs intervention. Can the team find the pending operation, understand the reason and identify who may resume it?
Also validate incoming notification authenticity, the permissions used by each system and access to reprocessing tools. Operational records should retain enough references for investigation without exposing passwords, tokens or unnecessary personal data.
Frequently asked questions
Does a timeout mean the payment did not happen?
No. It means the response did not arrive in time. Query the result using the original reference and follow the API contract before attempting a new operation.
Does using a queue prevent duplicate messages?
Not by itself. The design must handle redelivery, define when processing is acknowledged and recognize completed operations.
Can the same identifier be used for every charge?
No. An identifier must represent a specific intent. Reusing a key for different operations could block a legitimate charge or create a conflict, depending on the service contract.
Where should we start with an existing integration?
Choose an important workflow, identify shared references and map its states. Then check how it handles lost responses, duplicates, outages and recovery of pending operations.
How Fidalgo IT Solutions can help
Fidalgo IT Solutions can support integration design and reviews by connecting business states, API contracts and recovery mechanisms.
The work may include idempotency, asynchronous processing, reconciliation and monitoring of pending operations. The aim is to help the team identify what happened, what remains to be done and how each operation can be resumed with control.
Explore our APIs and integrations services or custom software development. To review a workflow across your systems, talk to Fidalgo.
References
- Amazon Builders' Library: idempotent APIs.
- Amazon Builders' Library: timeouts, retries and jitter.
- RabbitMQ: publisher confirms and consumer acknowledgements.
- AWS Prescriptive Guidance: transactional outbox.
- Microsoft Azure Architecture Center: compensating transactions.
Sources reviewed on November 9, 2026.
