Async

An instance of the forvendi.BreezzApi.BreezzAsync encapsulates methods for executing asynchronous processes.


executeBatch(String processName, String batchClassName, Database.Batchable batch)

Executes a batchable process.

Signature:

forvendi.BreezzApi.ASYNC.executeBatch(String processName, String batchClassName, Database.Batchable<Object> batch)

Parameters:

  • processName - the name of the process to be executed.
  • batchClassName - the name of the bath class to be executed.
  • batch - the batchable instance to be executed.

Return Value:

void

Usage:

 1public with sharing class BreezzBatch implements Database.Batchable<Object>,Database.Stateful {
 2    public BreezzBatch(){}
 3   
 4    public List<Object> start(Database.BatchableContext BC) {
 5        // collect the batches of records or objects to be passed to execute
 6        String query = 'SELECT Id, Name FROM Account';
 7        return (List<Object>)Database.query(query);
 8    }
 9     
10    public void execute(Database.BatchableContext BC, List<Object> accList) {
11        // process each batch of records default size is 200
12        List<Contact> cnts = new List<Contact>();
13        for (Object item : accList) {
14            Account acc = (Account) item;
15            cnts.add(new Contact(
16                    AccountId = acc.Id,
17                    Title = 'Batch test Title',
18                    LastName = 'Batch Test Last Name'));
19        }
20        try {
21            Database.upsert(cnts);
22        } catch (Exception e) {
23            forvendi.BreezzApi.LOGGER.logError('BreezzBatch', 'execute', 'Contact upsert batch');
24        }
25    }  
26     
27    public void finish(Database.BatchableContext BC) {
28        // execute any post-processing operations like sending email
29    }
30}

Above code is simple batch to create Contact and adding them to the Account

forvendi.BreezzApi.ASYNC.executeBatch('BreezzBatch', 'BreezzBatch',new BreezzBatch());

Above code is running the batch with custom operation.


publish(AsyncRequest request)

Publishes a single async request.

Signature:

forvendi.BreezzApi.ASYNC.publish(AsyncRequest request);

Parameters:

  • request - the async request to be published.

Return Value:

void

Usage:

forvendi.AsyncRequest request = new forvendi.AsyncRequest('Asynchronous Test','MultiQueueable');
forvendi.BreezzApi.ASYNC.publish(request);

publish(AsyncRequest[] request)

Publishes an array of async requests.

Signature:

forvendi.BreezzApi.ASYNC.publish(AsyncRequest[] requests);

Parameters:

  • request - the array of async requests to be published.

Return Value:

void

Usage:

1forvendi.AsyncRequest request = new forvendi.AsyncRequest[] {
2  new forvendi.AsyncRequest('Asynchronous Test','MultiQueueable'),
3  new forvendi.AsyncRequest('Asynchronous Test2','MultiQueueable')};
4forvendi.BreezzApi.ASYNC.publish(request);

publish(AsyncRequest[] requests, ModificationContext ctx)

Publishes an array of async requests with a modification context.

Signature:

forvendi.BreezzApi.ASYNC.publish(AsyncRequest requests, ModificationContext ctx);

Parameters:

  • request - the array of async requests to be published.
  • ctx - the modification context to be used for the publish operation.

Return Value:

void