Salesforce Decode
Salesforcedecode
Back to questions
ApexIntermediatequeueablecalloutsintegration

Chain Queueable jobs for sequential ERP callouts without losing pipeline state

Real World Scenario

Order export requires authenticate, create header, create lines, and confirm shipment—four REST callouts that must run in order with retry on transient failures.

Expected Answer

• Each Queueable implements AllowsCallouts and enqueues next step on success • Persist pipeline state on Staging_Order__c: step, correlation Id, last error • Idempotent steps: re-query ERP status before re-create on retry • Max chain depth 50—use batch for pipelines exceeding safe chain length • Dead letter status for manual retry UI after max attempts • Never store HttpResponse bodies in stateful vars—store parsed IDs only • Test full chain with HttpCalloutMock sequence per step

Follow-Up Questions & Answers

Click to expand — each follow-up includes a direct, interview-ready answer

Main difference: use case and scale. Each Queueable implements AllowsCallouts and enqueues next step on success. Persist pipeline state on Staging_Order__c: step, correlation Id, last error. Pick based on your integration pattern and team capability. Queueable chains without persisted state are lost on failure—database-backed pipeline state is mandatory. Balance speed of delivery with maintainability.

Architect Perspective

Queueable chains without persisted state are lost on failure—database-backed pipeline state is mandatory.