Salesforce Decode
Salesforcedecode
Back to questions
IntegrationArchitect (Hardest)sagadistributed-transactionserp

Design saga pattern for distributed transactions across Salesforce and ERP

Real World Scenario

Order creation requires Salesforce Opportunity update, SAP order create, and inventory reserve; any step failure must compensate prior steps.

Expected Answer

• Choreography: each service publishes event next step subscribes • Orchestration: middleware saga coordinator tracks step status • Compensating transactions: cancel SAP order if Salesforce fails • Saga state machine custom object or middleware persistence • Timeout each step triggering compensation not infinite wait • Idempotent steps safe to retry without double effect • Manual intervention queue for compensation failures

Follow-Up Questions & Answers

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

Main difference: use case and scale. Choreography: each service publishes event next step subscribes. Orchestration: middleware saga coordinator tracks step status. Pick based on your integration pattern and team capability. Distributed transactions need sagas—two-phase commit impossible across Salesforce and SAP. Document the decision in an ADR and align with enterprise standards.

Architect Perspective

Distributed transactions need sagas—two-phase commit impossible across Salesforce and SAP.