Salesforce Developers Salesforce Consultants Salesforce Salesforce Developers

HELLO|WELCOME TO CLOUD HELP|A SALESFORCE SOLUTION|WE LOVE TO DO CREATIVE THINGS|SALESFORCE CONSULTANTS FROM INDIA

Queueable Apex in Salesforce


















Queueable Apex is essentially a superset of future methods with some extra features, released in Winter 15. We can say its a mixer of future methods and the power of Batch Apex! It is called by a simpleSystem.enqueueJob() method, which returns a job ID like Apex batch that you can monitor.

Queueable Apex allows following additional benefits:

  • Non-primitive types: Your Queueable class can contain member variables of non-primitive data types, such as sObjects or custom Apex types. Those objects can be accessed when the job executes.
  • Monitoring: When you submit your job by invoking the System.enqueueJob method, the method returns the ID of the AsyncApexJob record. You can use this ID to identify your job and monitor its progress, either through the Salesforce user interface in the Apex Jobs page, or programmatically by querying your record from AsyncApexJob.
  • Chaining jobs: You can chain one job to another job by starting a second job from a running job. Chaining jobs is useful if you need to do some sequential processing.

Example:
public class AddContact implements Queueable {
    
    private Contact contact;
    private String sta;
    
    public AddContact(Contact con, String state) {
        this.contact = con;
        this.sta = state;
    }

    public void execute(QueueableContext context) {
        List<Account> accounts = [Select ID from Account where BillingState =:sta LIMIT 200];
        List<Contact> lstCon = new List<Contact>();
        for (Account account : accounts) {
            Contact clonedcon = contact.clone(false, false, false, false);  
            clonedcon.AccountID = account.ID;
            lstCon.Add(clonedcon);
        }
        insert lstCon;
    }    
}

Share this:

CONVERSATION

1 comments:

  1. Thanks for sharing informative article on Salesforce technology. Your article helped me a lot to understand the career prospects in cloud computing technology. Cloud Computing Training in Chennai|cloud computing training chennai

    ReplyDelete

Navneet kumar, Software consultant from delhi, India. Basically from Bisfi, Madhubani Bihar. Software Engineer!

Navneet kumar bisfi madhubani bihar

Navneet bisfi madhubani bihar

Nabu Nabbu bisfi madhubani bihar

Navneet Software consultant from delhi

Navneet kumar Software consultant from delhi

Navneet kumar Software Engineer bisfi madhubani bihar

Nabu Nabbu Software Engineer bisfi madhubani bihar

bisfi madhubani bihar

Salesforce

Salesforce Consultant

Salesforce Developer

Salesforce Best Blog

Salesforce Cloud Computing

Cloud Computing

Salesforce Customizations

Salesforce Developments

Apex Salesforce

Apex Controllers

Salesforce Triggers, classes, work flows