UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest
Class
global inherited sharing class UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequestRequest object for initiating an asynchronous process.
Since: 1.0
Properties
| Property | Description |
|---|---|
| global AsyncOptions asyncOptions | AsyncOptions for configuring queueable behavior, especially useful for tests. |
| global Integer batchJobSize | The number of records to process in each Batch Apex transaction. |
| global Integer delayMinutes | The delay in minutes before processing starts. |
| global IF_Async.AsynchronousExecutionStrategy executionStrategy | The execution strategy for queueable processing. |
| global List itemsToProcess | The list of objects to process. |
| global Integer limitAtWhichToBatch | The record count threshold at which the framework switches from Queueable to Batch Apex. |
| global IF_Queryable queryable | The queryable used for query-based jobs. |
| global Integer queueableJobSize | The number of records to process in each Queueable job transaction. |
Methods
| Method | Description |
|---|---|
| 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
global AsyncOptions asyncOptionsType: AsyncOptions
AsyncOptions for configuring queueable behavior, especially useful for tests. When set, this will be passed to System.enqueueJob calls.
Since:
Example:
batchJobSize
global Integer batchJobSizeType: Integer
The number of records to process in each Batch Apex transaction.
Since:
Example:
delayMinutes
global Integer delayMinutesType: 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
global IF_Async.AsynchronousExecutionStrategy executionStrategyType: IF_Async.AsynchronousExecutionStrategy
The execution strategy for queueable processing. Default: AUTO (framework decides based on context and limits).
Since:
Example:
itemsToProcess
global List<Object> itemsToProcessType: List
The list of objects to process. Null for query-based jobs.
Since:
Example:
limitAtWhichToBatch
global Integer limitAtWhichToBatchType: Integer
The record count threshold at which the framework switches from Queueable to Batch Apex.
Since:
Example:
queryable
global IF_Queryable queryableType: IF_Queryable
The queryable used for query-based jobs. Null for list-based jobs.
Since:
Example:
queueableJobSize
global Integer queueableJobSizeType: Integer
The number of records to process in each Queueable job transaction.
Since:
Example:
Method Details
DTO_AsynchronousJobRequest
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:
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
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:
UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest instance = new UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest(new List<Object>{'a', 'b'});withAsyncOptions
global UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest withAsyncOptions(AsyncOptions options)Sets the maximum stack depth for chaining
Parameters:
options(AsyncOptions) - The asynchronous options to use
Returns: UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest - The AsynchronousJobRequest instance for method chaining.
Since: 1.0
Example:
DTO_AsynchronousJobRequest result = instance.withAsyncOptions(new AsyncOptions());withBatchSize
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:
DTO_AsynchronousJobRequest result = instance.withBatchSize(10);withDelayMinutes
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:
- IllegalArgumentException - if minutes is less than 0.
Since: 1.0
Example:
// 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
global UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest withExecutionStrategy(IF_Async.AsynchronousExecutionStrategy strategy)Sets the execution strategy for determine what job type to use
Parameters:
strategy(IF_Async.AsynchronousExecutionStrategy) - The execution strategy to employ
Returns: UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest - The AsynchronousJobRequest instance for method chaining.
Since: 1.0
Example:
DTO_AsynchronousJobRequest result = instance.withExecutionStrategy(new IF_Async.AsynchronousExecutionStrategy());withLimitAtWhichToBatch
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:
DTO_AsynchronousJobRequest result = instance.withLimitAtWhichToBatch(10);withQueueableJobSize
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:
DTO_AsynchronousJobRequest result = instance.withQueueableJobSize(10);