Posted in Salesforce

Difference between future method batch class and queueable apex

@future can only be applied on a method whereas quaueable interface allows us to declare the complete class as asynchronous.

It supports all data types unlike future method which only supports sobject types.

Future methods cannot be monitored where quaueable apex can be monitored using the job id which is returned by system.enqueuejob().

we cannot call another future method from a future method but we can call another quaueable apex from a quaueable class, which is called job chaining.

Quaueable apex does not have start and finish method as in batch class.

Future methods can be contained inside a synchronous class that means we can switch between synchronous and asynchronous where queueable apex is solely asynchronous.

For further understanding of Queueable


Posted in Salesforce

Calling Queueable Interface from Trigger/Class/Controller in Salesforce.

To call a Queueable class from you Trigger/Class/Controller simply place use “System.enqueueJob(new ClassName())”.


trigger AccountTrigger on Account (before insert) {
System.enqueueJob(new QueueableExample(Trigger.New));