How do enterprise architects evaluate and choose between Future, Queueable, Batch, and Scheduled Apex for complex integration workflows?
Answer
Basics: All four run outside the user's transaction with higher limits. They differ in volume handling, parameters, monitoring and chaining.
How it works / decision guide:
- Future (
@future): static, void, primitive or collection-of-primitive parameters, up to 50 per transaction, no Id returned, cannot be called from batch or future. Legacy; mostly replaced by Queueable. - Queueable: object parameters (sObjects, custom types), returns a job Id, can chain one child from a running job, supports Finalizers and
AsyncOptions; 50 enqueues per sync transaction. - Batch: millions of records (QueryLocator up to 50 million), scope 1 to 2000, 5 concurrent plus 100 in the Flex Queue, Stateful option.
- Scheduled: cron-driven (max 100 jobs), runs as a thin launcher.
Advanced / deep dive: For integrations: event-driven outbound calls fit a trigger enqueuing a Queueable with Database.AllowsCallouts and a Finalizer for retry; high-volume sync fits Scheduled launching Batch with Database.AllowsCallouts and a callout-safe scope; near real-time fan-out fits platform events or Change Data Capture rather than polling. Consider the daily async execution limit (greater of 250,000 or licenses x 200), callout limits (100 per transaction, 120 s cumulative), idempotency, retries with backoff, and observability (log object plus BatchApexErrorEvent). Also evaluate declarative options (Flow scheduled paths, async paths, Orchestrator) and newer Apex Cursors for large paging (verify release availability).
Code / config example:
// Scheduled dispatcher launches the right async tool
{
{
Database.executeBatch( (), );
}
}