# How does the Fire-And-Forget pattern optimize asynchronous processing during high-volume outbound data transfers?

**Topic:** Integration · **Difficulty:** Medium · **Tags:** Integration, Integration Patterns, Fire and Forget

Read it on the site: https://www.forcechallenges.com/interview-questions/how-does-the-fire-and-forget-pattern-optimize-asynchronous-processing-during-high-volume-outbound-data

## Answer

**Basics:** Instead of blocking on the remote system, Salesforce hands off the work: it publishes an event, sends an outbound message, or enqueues an async job that performs the callout later. Use it for notifications, order submissions or data pushes where the user does not need the result immediately. The trade-off is that you only get "accepted for delivery", not the final outcome.

**How it works:**
1. Record change in Salesforce.
2. Publish a platform event (`EventBus.publish`) or Change Data Capture event, create an outbound message, or enqueue Queueable/`@future(callout=true)`.
3. A subscriber (middleware via Pub/Sub API or CometD, or an Apex/Flow trigger) delivers it to the target.
4. The target acknowledges delivery to the bus; any real result comes back later via a Remote Call-In (callback) if needed.

**Advanced / deep dive:** Delivery is at-least-once, so consumers must be idempotent (carry a unique key such as the record Id plus version). Ordering is by ReplayId within a channel, not guaranteed globally. Events published "after commit" disappear if the transaction rolls back, which keeps data consistent; "publish immediately" events survive rollbacks, which suits logging. Platform event publishing and delivery are governed by allocations (hourly publish and 24-hour delivery limits that depend on edition and add-ons; verify in current limits docs). Queueable chaining allows only one child per running job, so high-volume outbound work usually goes through events plus middleware, which can batch, retry and throttle. Fire and Forget does not remove error handling: you still need monitoring and a dead-letter strategy for messages that never get processed.

**Code / config example:**
```apex
List<Order_Submitted__e> events = new List<Order_Submitted__e>();
for (Order o : orders) {
    events.add(new Order_Submitted__e(Order_Id__c = o.Id, Payload__c = JSON.serialize(o)));
}
List<Database.SaveResult> results = EventBus.publish(events);   // one call, bulk-safe
for (Database.SaveResult sr : results) {
    if (!sr.isSuccess()) { /* log sr.getErrors() */ }
}
```

**Hidden gotchas & must-remember points:**
- A successful publish means "queued", not "delivered or processed".
- `@future` max 50 per transaction and primitives only; Queueable max 50 enqueues per sync transaction.
- Outbound messages are SOAP-only and tied to Workflow Rules, which are retired; use platform events or Flow-triggered callouts for new work.
- Events are not queryable like records and are retained only for the replay window (72 hours for high-volume).
- Duplicates and reordering must be tolerated by the receiver.

**Best practice:** Use events for outbound integration, design receivers to be idempotent, and monitor for failures rather than assuming success.

---
Source: ForceChallenges · last updated 2026-11-02
