3

With the introduction of Change Data Capture, now there is one more way to execute Asynchronous Apex.

What are the advantages of Change Data Capture over Queueable Apex?

How Salesforce will enqueue CDC, Queuable, Future method if all three are getting executed from a single record?

Would there be any governor limits on Change Data Capture? Limits are not mentioned in CDC Guide

3

The main difference between them is "context".

A Queueable (or a @future) is called by the developer. It can be called in any operation (trigger, visualforce, flow, schedule, Aura/LWC, etc), but we have a limit on the number of queueable jobs we can schedule in a single transaction (50 in the original transaction, 1 if you are already in a future context). You control when it runs and which kind of information is available at the beggining (it can be anything: a list of ids, a single object, a string or even nothing).

A Change Data Capture trigger is run EVERYTIME there's a DML operation (create, update, delete or undelete) on a record, and it is called by Salesforce (so it does not have limits about how many triggers you can call). You don't control the input, it's always the object with a list of changed fields.

How Salesforce will enqueue CDC, Queuable, Future method if all three are getting executed from a single record?

I don't have hard info on this, but as with all Salesforce asynch calls you should NOT rely on time or order of execution. My guess is that events run before as they are "Salesforce based" and run everytime, followed by Queueable/@future by order in which they were called (they share the same queue)

  • Thanks @Fernando for valuable inputs! – Devendra Aug 13 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.