ShopX

Menu

24/7 Support
Back to Blog
OpenCart module development
PHP integration queues for OpenCart: retries without duplicates

PHP integration queues for OpenCart: retries without duplicates

An external carrier or marketplace can finish an operation after the original OpenCart request times out. When a job is retried, the shop must preserve the identity of the logical operation. Otherwise the remote service can create a second shipment or confuse the state of an order.

Practical check. Simulate a remote success with a lost response. Your staging retry should result in one remote record and one completed logical job.

Make retries safe before you schedule them

Give each operation an idempotency key derived from its business identity and intended version. Store it with a unique constraint where applicable. Pass the same key to the remote API if it supports idempotency. If the service lacks this feature, reconcile the remote state by a stable reference before retrying an ambiguous operation. A local unique key alone cannot prevent a second external effect.

CheckWhat it showsWhere to verify
Transport timeoutReconcile or reuse the same idempotency keyResolve ambiguous outcomes
429 rate limitWait per provider contractAdd bounded jitter when suitable
Invalid payloadStop automatic retriesReview and correct the data
Worker crashReclaim after the leasePreserve logical identity

Choose delay, limits and recovery rules

Claim a job conditionally using a bounded lease and keep the outgoing request outside a long-running database transaction. Use capped exponential delay with jitter for eligible retries. Respect the API's retry contract and Retry-After when relevant. Limit the total age and attempt count. Avoid stacking retries at the client, worker and scheduler layers.

Send exhausted jobs or permanent failures to a dead-letter workflow. Capture the job ID, store, operation, attempts and a safe error code. Before replay, check that the data and account are still current. Track the queue's oldest age alongside errors and retry frequency. Inject an intentional lost response in staging to see whether duplicate prevention actually works.

Frequently asked questions

Why can an HTTP timeout still produce a shipment?

The provider may have completed its work before the response was lost.

Should I retry every 4xx?

Follow the provider contract. A rate limit can be temporary, while an invalid request needs intervention.

What should an operator check before replay?

Confirm the job version and remote state, and use the existing idempotency key when repeating the same operation.

Share:
← Previous
crm prom: a practical guide to connecting and processing orders

Related Posts

Instant deliveryFiles immediately after payment
Regular updatesLatest module versions
Secure paymentProtected purchase
Technical supportWe will help with the setup