Skip to content

Async Lib

Handle complex asynchronous operations in Apex. Chain queueable jobs, manage delays, and implement retry logic with a simple API.

API version

License

GitHub Repo starsGitHub ReleaseCodecov

Why Async Lib?

  • Eliminates Queueable Limits - Automatically handles "Too many queueable jobs" by intelligent chaining and batch overflow.
  • Unified API - Single, consistent interface for all async job types (Queueable, Batchable, Schedulable).
  • Smart Prioritization - Jobs execute based on priority with automatic sorting.
  • Advanced Error Handling - Built-in error recovery, rollback options, and continuation strategies.
  • Job Tracking - Comprehensive tracking with custom job IDs and result records.
  • Configuration-Driven - Control job behavior through custom metadata without code changes.
  • Support Finalizers - Execute cleanup logic after job completion with full context.

Quick Start

apex
public class MyQueueableJob extends QueueableJob {
    public override void work() {
        // Your business logic here
        System.debug('Processing job: ' + Async.getQueueableJobContext().currentJob.customJobId);
    }
}
apex
// Queueable Job
Async.queueable(new MyQueueableJob())
    .priority(10)
    .delay(5)
    .enqueue();

// Batch Job
Async.batchable(new MyBatchJob())
    .scopeSize(100)
    .execute();

// Schedulable Job
Async.schedulable(new MySchedulableJob())
    .name('Daily Cleanup')
    .cronExpression('0 0 2 * * ? *')
    .skipWhenAlreadyScheduled()
    .schedule();

Documentation

Installation

Choose the best installation option for you:

Released under the MIT License.