This class provides a way for developers to create a process of Queueable classes. This implementation
facilitates the handoff of data into the overarching process and from one process step to the next. While
functionally similar to the way a 'Promise' pattern allows you chain async methods together. However, a true Promise
pattern resolves itself, one way or another, within the same transaction. Therefore, this is not a true Promise
pattern, but an elegant way to logically chain Salesforce Queueables together. As a Developer, you'll need to extend
this class, implementing the necessary execute method. Your execute method will be invoked asynchronously as part
of a Queueable. You can then chain additional Queueables together using the then method provided by this class.
<br>
As each 'step' of the chain is completed the transaction finalizer will be constructed with the remaining steps and
any passthrough data you specify. Passthrough data allows you to pass data between steps.
Implements
Queueable, Database.AllowsCallouts
public processStepsList<QueueableProcess>
public dataPassthroughObject
public queueableContextHistoryList<QueueableContext>
public finalizerContextHistoryList<FinalizerContext>
TESTVISIBLE
private static defaultHandleExceptionCalledBoolean
SUPPRESSWARNINGS
this is a constructor that is used by extension classes;
protected QueueableProcess()This method provides a syntactic sugar for adding a new QueueableProcess to the chain.
public QueueableProcess then(QueueableProcess toAdd)| Name | Type | Description |
|---|---|---|
| toAdd | QueueableProcess | An instance of a class that extends this QueueableProcess class and implements the execute method. |
Returns a Queueable Process instance that can be used to chain additional QueueableProcess instances.
This method starts the QueueableProcess chain. It's the entry point for the process.
public Id start()Id
Id - Id of the Enqueued job.
This method starts the QueueableProcess chain. It's the entry point for the process.
public Id start(Object initialPassthrough)| Name | Type | Description |
|---|---|---|
| initialPassthrough | Object | Object - this is the initial passthrough data that will be passed to the first |
| QueueableProcess in the chain. |
Id
Id - Id of the Enqueued job.
This must be implemented by extending classes. Developers - implement this method with the work you want executed asynchronously.
public abstract void execute()void
this is a default implementation of an handleError method. It's called by the finalizer if the
developer doesn't implement their own handleError method. Developers can write per-step error handling
by implementing their own handleError method as public override void handleError(Exception incomingException)
public virtual void handleException(Exception incomingException)| Name | Type | Description |
|---|---|---|
| incomingException | Exception | Exception - the exception that was thrown during execution. |
void
This is required by the Queueable interface. It's the essence of how the QueueableProcess pattern is implemented in Apex.
public virtual void execute(QueueableContext context)| Name | Type | Description |
|---|---|---|
| context | QueueableContext | QueueableContext - dependency injected by Salesforce at execution time. |
void