Skip to content

UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest

Class

apex
global inherited sharing class UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest

Request object for initiating an asynchronous process.

Since: 1.0


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 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.

Methods

MethodDescription
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.
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.

Property Details

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.

Since:

Example:

batchJobSize

apex
global Integer batchJobSize

Type: Integer

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

Since:

Example:

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.

Since:

Example:

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).

Since:

Example:

itemsToProcess

apex
global List<Object> itemsToProcess

Type: List

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

Since:

Example:

limitAtWhichToBatch

apex
global Integer limitAtWhichToBatch

Type: Integer

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

Since:

Example:

queryable

apex
global IF_Queryable queryable

Type: IF_Queryable

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

Since:

Example:

queueableJobSize

apex
global Integer queueableJobSize

Type: Integer

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

Since:

Example:


Method Details

DTO_AsynchronousJobRequest

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:

  • queryable (IF_Queryable) - The IF_Queryable defining the records to process.

Since: 1.0

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

apex
global DTO_AsynchronousJobRequest(List<Object> items)

Constructor for processing a predefined list of objects.

Parameters:

  • items (List) - The list of objects to process.

Since: 1.0

Example:

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

withAsyncOptions

apex
global UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest withAsyncOptions(AsyncOptions options)

Sets the maximum stack depth for chaining

Parameters:

Returns: UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest - The AsynchronousJobRequest instance for method chaining.

Since: 1.0

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:

  • size (Integer) - The number of items per batch execution.

Returns: UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest - The AsynchronousJobRequest instance for method chaining.

Since: 1.0

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:

  • minutes (Integer) - The delay in minutes before processing begins (0 or greater).

Returns: UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest - The AsynchronousJobRequest instance for method chaining.

Throws:

Since: 1.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:

Returns: UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest - The AsynchronousJobRequest instance for method chaining.

Since: 1.0

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:

  • threshold (Integer) - The number of items that will trigger Batch Apex execution.

Returns: UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest - The AsynchronousJobRequest instance for method chaining.

Since: 1.0

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:

  • size (Integer) - The number of items per Queueable execution.

Returns: UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest - The AsynchronousJobRequest instance for method chaining.

Since: 1.0

Example:

apex
DTO_AsynchronousJobRequest result = instance.withQueueableJobSize(10);