Skip to content

UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest ​

Class

apex
global inherited sharing class UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest

Request object for initiating an asynchronous process.


Methods ​

MethodDescription
global UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest withAsyncOptions(AsyncOptions options)Sets the maximum stack depth for chaining
global UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest withBatchSize(Integer size)Sets the batch job size for Batch Apex execution.
global UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest withDelayMinutes(Integer minutes)Sets the delay in minutes before processing starts.
global UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest withExecutionStrategy(IF_Async.AsynchronousExecutionStrategy strategy)Sets the execution strategy for determine what job type to use
global UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest withLimitAtWhichToBatch(Integer threshold)Sets the threshold at which processing switches from Queueable to Batch Apex.
global UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest withQueueableJobSize(Integer size)Sets the chunk size for Queueable execution.

withAsyncOptions ​

apex
global UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest withAsyncOptions(AsyncOptions options)

Sets the maximum stack depth for chaining

Parameters

ParameterTypeDescription
optionsAsyncOptionsThe asynchronous options to use

Returns UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest — The AsynchronousJobRequest instance for method chaining.

Example

apex
DTO_AsynchronousJobRequest result = instance.withAsyncOptions(new AsyncOptions());

withBatchSize ​

apex
global UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest withBatchSize(Integer size)

Sets the batch job size for Batch Apex execution.

Parameters

ParameterTypeDescription
sizeIntegerThe number of items per batch execution.

Returns UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest — The AsynchronousJobRequest instance for method chaining.

Example

apex
DTO_AsynchronousJobRequest result = instance.withBatchSize(10);

withDelayMinutes ​

apex
global UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest withDelayMinutes(Integer minutes)

Sets the delay in minutes before processing starts. For delays greater than 10 minutes, the framework automatically chains queueables until the delay expires, making this suitable for any duration.

Parameters

ParameterTypeDescription
minutesIntegerThe delay in minutes before processing begins (0 or greater).

Returns UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest — The AsynchronousJobRequest instance for method chaining.

Throws

ExceptionDescription
IllegalArgumentExceptionif minutes is less than 0.

Example

apex
// Process immediately (default)
DTO_AsynchronousJobRequest request = new DTO_AsynchronousJobRequest(items);
// Process after 5 minutes
DTO_AsynchronousJobRequest request = new DTO_AsynchronousJobRequest(items)
    .withDelayMinutes(5);
// Process after 45 minutes (automatically chains for delays > 10 min)
DTO_AsynchronousJobRequest request = new DTO_AsynchronousJobRequest(items)
    .withDelayMinutes(45);
Id jobId = UTIL_AsynchronousJobLauncher.process(request, new MyProcessor());

withExecutionStrategy ​

apex
global UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest withExecutionStrategy(IF_Async.AsynchronousExecutionStrategy strategy)

Sets the execution strategy for determine what job type to use

Parameters

ParameterTypeDescription
strategyIF_Async.AsynchronousExecutionStrategyThe execution strategy to employ

Returns UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest — The AsynchronousJobRequest instance for method chaining.

Example

apex
DTO_AsynchronousJobRequest result = instance.withExecutionStrategy(new IF_Async.AsynchronousExecutionStrategy());

withLimitAtWhichToBatch ​

apex
global UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest withLimitAtWhichToBatch(Integer threshold)

Sets the threshold at which processing switches from Queueable to Batch Apex.

Parameters

ParameterTypeDescription
thresholdIntegerThe number of items that will trigger Batch Apex execution.

Returns UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest — The AsynchronousJobRequest instance for method chaining.

Example

apex
DTO_AsynchronousJobRequest result = instance.withLimitAtWhichToBatch(10);

withQueueableJobSize ​

apex
global UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest withQueueableJobSize(Integer size)

Sets the chunk size for Queueable execution.

Parameters

ParameterTypeDescription
sizeIntegerThe number of items per Queueable execution.

Returns UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest — The AsynchronousJobRequest instance for method chaining.

Example

apex
DTO_AsynchronousJobRequest result = instance.withQueueableJobSize(10);

Constructors ​

ConstructorDescription
global DTO_AsynchronousJobRequest(IF_Queryable queryable)Constructor for processing records retrieved from an IF_Queryable.
global DTO_AsynchronousJobRequest(List<Object> items)Constructor for processing a predefined list of objects.

DTO_AsynchronousJobRequest(IF_Queryable queryable) ​

apex
global DTO_AsynchronousJobRequest(IF_Queryable queryable)

Constructor for processing records retrieved from an IF_Queryable. Supports QRY_Builder.Builder and SEL_Base instances directly.

Parameters

ParameterTypeDescription
queryableIF_QueryableThe IF_Queryable defining the records to process.

Example

apex
IF_Queryable query = QRY_Builder.selectFrom(Account.SObjectType)
    .fields(new List<String>{'Id', 'Name'})
    .condition(Account.Industry).equals('Technology');
DTO_AsynchronousJobRequest request = new DTO_AsynchronousJobRequest(query)
    .withBatchSize(100);
Id jobId = UTIL_AsynchronousJobLauncher.process(request, new MyProcessor());

DTO_AsynchronousJobRequest(List<Object> items) ​

apex
global DTO_AsynchronousJobRequest(List<Object> items)

Constructor for processing a predefined list of objects.

Parameters

ParameterTypeDescription
itemsListThe list of objects to process.

Example

apex
UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest instance = new UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest(new List<Object>{'a', 'b'});

Properties ​

PropertyDescription
global AsyncOptions asyncOptionsAsyncOptions for configuring queueable behavior, especially useful for tests.
global Integer batchJobSizeThe number of records to process in each Batch Apex transaction.
global Integer delayMinutesThe delay in minutes before processing starts.
global IF_Async.AsynchronousExecutionStrategy executionStrategyThe execution strategy for queueable processing.
global List<Object> itemsToProcessThe list of objects to process.
global Integer limitAtWhichToBatchThe record count threshold at which the framework switches from Queueable to Batch Apex.
global IF_Queryable queryableThe queryable used for query-based jobs.
global Integer queueableJobSizeThe number of records to process in each Queueable job transaction.

asyncOptions ​

apex
global AsyncOptions asyncOptions

Type: AsyncOptions

AsyncOptions for configuring queueable behavior, especially useful for tests. When set, this will be passed to System.enqueueJob calls.

batchJobSize ​

apex
global Integer batchJobSize

Type: Integer

The number of records to process in each Batch Apex transaction.

delayMinutes ​

apex
global Integer delayMinutes

Type: Integer

The delay in minutes before processing starts. For delays greater than 10 minutes, the framework automatically chains queueables until the delay expires.

executionStrategy ​

apex
global IF_Async.AsynchronousExecutionStrategy executionStrategy

Type: IF_Async.AsynchronousExecutionStrategy

The execution strategy for queueable processing. Default: AUTO (framework decides based on context and limits).

itemsToProcess ​

apex
global List<Object> itemsToProcess

Type: List

The list of objects to process. Null for query-based jobs.

limitAtWhichToBatch ​

apex
global Integer limitAtWhichToBatch

Type: Integer

The record count threshold at which the framework switches from Queueable to Batch Apex.

queryable ​

apex
global IF_Queryable queryable

Type: IF_Queryable

The queryable used for query-based jobs. Null for list-based jobs.

queueableJobSize ​

apex
global Integer queueableJobSize

Type: Integer

The number of records to process in each Queueable job transaction.