Choosing an Integration Pattern
By the end of this lesson, you'll be able to:
- Compare synchronous and asynchronous integration patterns
- Choose request-and-reply, fire-and-forget, or batch data sync for a given scenario
Prerequisites: SOAP Callouts and WSDL2Apex
Synchronous: request-and-reply
A user-triggered action calls an external system and waits for the response before continuing — e.g. a button that looks up a customer's credit score in real time. Simple, but it blocks the transaction and is subject to Apex's callout limits (100 callouts, 120 seconds cumulative timeout per transaction).
Asynchronous: fire-and-forget and batch sync
Fire-and-forget uses Queueable Apex or Platform Events to hand off work without waiting for a reply — good for logging or notifications where the caller doesn't need the result. Scheduled batch data sync (Scheduled Apex driving Batch Apex, or an external ETL tool) handles large volumes on a timer instead of per-transaction, avoiding real-time governor limits entirely.
A fire-and-forget Queueable callout
public class NotifyExternalSystem implements Queueable, Database.AllowsCallouts {
public void execute(QueueableContext ctx) {
Http http = new Http();
http.send(buildRequest());
}
private HttpRequest buildRequest() {
return new HttpRequest();
}
}
System.enqueueJob(new NotifyExternalSystem());
The calling code returns immediately after enqueueJob() — it never waits for the external system to respond, which is exactly the point of a fire-and-forget pattern.
Exercise
A nightly job needs to sync 50,000 updated Contacts to an external marketing platform. Which integration pattern fits, and why not a synchronous callout?
Show hint
Think about Apex's per-transaction callout limits versus what runs on a schedule.
Choosing an Integration Pattern — Quick Check
My Notes
Log in to keep private notes on this lesson.
Questions about this lesson
No questions yet — be the first to ask.
Log in to ask a question about this lesson.
Summary
Not every integration should be a synchronous callout — choosing between request-and-reply, fire-and-forget (via Queueable Apex or Platform Events), and scheduled batch data sync depends on whether the caller needs an immediate answer and how much data is involved.