Tuesday, 19 December 2017

Queueable Apex

What is Queueable Apex ?

This is combination of Batch & Future jobs.

Code Implementation  for a particular Account update the contact FirstName :


Queueable can be called from Batch ?

Yes,It can be called from Batch execute method.
Note : Only one enqueueJob call per execute

Ex:


Batch job can be called from Queueable ?

Yes,It's possible

Queueable can be called from Future methods?

No,It's not allowed

Future methods can be called from Queueable ?

Yes,It's possible

Queueable can be scheduled ?

Yes,It's allowed.

What are the features of Queueable over Future methods ?

1.Getting JobID 
2.Passing non-primitive types
3.Chaining Jobs

Queueable is super set of Future,So Future methods will be deprecated?

I don't think so,
Each one is designed for specific behavior.
Below are the cases where Future methods are more opt to use :
1.Future method is light weight and handy.
2.If we want a class to be synchronous and only some logic should be asynchronous.Marking method as future is easy.

Future methods are restricted to primitive datatypes,Because Objects could potentially change from the time it's passed to the time when the future method executes,Why this will not apply to Queueable Apex?

Ideally should avoid passing in entire Sobjects,Especially if they may change between serialization and execution.



No comments:

Post a Comment