Async
An instance of forvendi.BreezzApi.BreezzAsync (accessible via forvendi.BreezzApi.ASYNC) encapsulates utility methods for executing asynchronous processes, publishing async requests, and running batch jobs.
executeBatch(String processName, String batchClassName, Database.Batchable<Object> batch)
Executes a batchable process through the Breezz execution wrapper.
Signature:
public void executeBatch(String processName, String batchClassName, Database.Batchable<Object> batch)Parameters:
processName: The developer name of the asynchronous process to be executed.batchClassName: The name of the Batch Apex class being executed.batch: The batchable class instance (Database.Batchable<Object>).
Return Value: void
Usage Example:
public with sharing class BreezzBatch implements Database.Batchable<Object>, Database.Stateful {
public BreezzBatch() {}
public List<Object> start(Database.BatchableContext BC) {
String query = 'SELECT Id, Name FROM Account';
return (List<Object>) Database.query(query);
}
public void execute(Database.BatchableContext BC, List<Object> accList) {
List<Contact> contactsToUpsert = new List<Contact>();
for (Object item : accList) {
Account acc = (Account) item;
contactsToUpsert.add(new Contact(
AccountId = acc.Id,
Title = 'Batch Test Title',
LastName = 'Batch Test Last Name'
));
}
try {
Database.upsert(contactsToUpsert);
} catch (Exception e) {
forvendi.BreezzApi.LOGGER.logError('BreezzBatch', 'execute', 'Contact upsert batch error');
}
}
public void finish(Database.BatchableContext BC) {
// Execute post-processing operations (e.g., sending notifications)
}
}To invoke the batch using Breezz API:
forvendi.BreezzApi.ASYNC.executeBatch('BreezzBatchProcess', 'BreezzBatch', new BreezzBatch());publish(AsyncRequest request)
Publishes a single asynchronous request to the Breezz processing queue.
Signature:
public void publish(forvendi.AsyncRequest request)Parameters:
request: The singleforvendi.AsyncRequestinstance to be published.
Return Value: void
Usage Example:
forvendi.AsyncRequest request = new forvendi.AsyncRequest('Asynchronous Test', 'MultiQueueable');
forvendi.BreezzApi.ASYNC.publish(request);publish(AsyncRequest[] requests)
Publishes an array of asynchronous requests in bulk.
Signature:
public void publish(forvendi.AsyncRequest[] requests)Parameters:
requests: An array offorvendi.AsyncRequestinstances to be published.
Return Value: void
Usage Example:
forvendi.AsyncRequest[] requests = new forvendi.AsyncRequest[] {
new forvendi.AsyncRequest('Asynchronous Test 1', 'MultiQueueable'),
new forvendi.AsyncRequest('Asynchronous Test 2', 'MultiQueueable')
};
forvendi.BreezzApi.ASYNC.publish(requests);publish(AsyncRequest[] requests, ModificationContext ctx)
Publishes an array of asynchronous requests within a specific ModificationContext.
Signature:
public void publish(forvendi.AsyncRequest[] requests, forvendi.ModificationContext ctx)Parameters:
requests: An array offorvendi.AsyncRequestinstances to be published.ctx: TheModificationContextinstance used to stage DML and execution context changes.
Return Value: void