ForceChallenges
ProblemsDailyNotesInterview
Sign in

Practice

All problemsSOQL practiceApex trigger challengesDaily challengeOpportunityTrigger.oldMapBefore UpdateBulkificationContactValidationGROUP BYSemi-JoinAccountBefore Insert

Interview questions

All questionsAdminAdministrationApexApex TriggerAsync ApexDevelopmentField ServiceField ServiceIntegrationLwc

By company

DeloitteSalesforceAccentureInfosysPwCCognizant

Learn

Study notes

ForceChallenges

AboutContact usPrivacy PolicyTerms of ServiceFor AI assistants (llms.txt)
© 2026 ForceChallenges · Salesforce SOQL & Apex trigger practice
Integration questions49 of 100
IntegrationMedium 2 min read

What purpose do dead-letter queues serve in managing failed integration transactions and preventing data loss?

Answer

Basics: In messaging, some messages can never succeed as sent (bad data, a deleted record, a bug), and endless retries just waste capacity. A DLQ isolates these "poison" messages. Salesforce has no single native DLQ product, so you build the pattern with what the platform offers, or rely on middleware (for example MuleSoft Anypoint MQ DLQs, or a broker such as Kafka or SQS).

How it works:

  1. Process a message; on failure retry a limited number of times with backoff.
  2. After the limit, persist the payload, correlation Id, error, attempt count and timestamp in a custom object (for example Integration_Failure__c) or Big Object.
  3. Alert owners (Flow, email, Slack, dashboard).
  4. After the fix, a replay job or admin action re-submits records marked "Ready to retry".

Advanced / deep dive: Platform building blocks:

  • Platform event triggers: throw EventBus.RetryableException to have Salesforce redeliver the batch (up to 9 retries); after that, you must catch and persist the failure yourself.
  • Queueable Finalizers (System.Finalizer, attached via System.attachFinalizer) run even after uncaught exceptions or limit failures and can log or re-enqueue.
  • Batch Apex: implement Database.RaisesPlatformEvents to receive BatchApexErrorEvent for unhandled failures in a batch scope.
  • Outbound messages queue and retry for 24 hours (extendable; verify the setting), and failed ones are visible in Setup, Monitor, Outbound Messages. Key design point: write the failure record in a transaction that will not roll back. If the failing transaction is rolled back, a plain insert of the log disappears with it; use a platform event published immediately, or log in a separate async transaction. Include enough payload to replay, mask sensitive data, and set retention rules.

Code / config example:

apex
public class SyncJob implements Queueable, Database.AllowsCallouts {
    public void execute(QueueableContext qc) {
        System.attachFinalizer(new SyncFinalizer(qc.getJobId()));
        // ... callout work that may throw
    }
}
public class SyncFinalizer implements Finalizer {
    private Id jobId;
    public SyncFinalizer(Id j) { jobId = j; }
    public void execute(FinalizerContext ctx) {
        if (ctx.getResult() == ParentJobResult.UNHANDLED_EXCEPTION) {
            insert new Integration_Failure__c(Job_Id__c = jobId,
                Error__c = ctx.getException().getMessage());
        }
    }
}

Hidden gotchas & must-remember points:

  • Retries without a cap create poison-message loops.
  • Logging inside a rolled-back transaction loses the log.
  • Replays must be idempotent, or you create duplicates.
  • Platform events expire after the replay window, so they cannot serve as long-term storage.
  • Store failures with a status field so replays are auditable.

Best practice: Cap retries, park failures with full context in a durable store, alert on arrival, and provide a controlled replay path.

IntegrationDead-Letter QueuesFault Tolerance
Practice SOQL & Apex
PreviousHow does the Fire-And-Forget pattern optimize asynchronous processing during high-volume outbound data transfers?Next How do developers optimize integration payload structures to prevent heap size exhaustion and serialization errors?

More Integration questions

  • How do PushTopics combine SOQL query criteria with real-time streaming notifications in Salesforce?
  • How do webhook security mechanisms verify the authenticity of incoming HTTP notifications from external systems?
  • How do federated identity and SAML single sign-on streamline authentication across enterprise integration landscapes?
  • How do CORS settings permit authorized web applications to perform cross-origin REST requests against Salesforce?
  • How do rate limiting and throttling mechanisms protect Salesforce endpoints from excessive traffic spikes?