Are queueable jobs actually queueable?

Do jobs placed in apex queue are actually executed the order they’ve been put in?

Or is this expected by developer to be implemented manually by using chaining?

Answer

No, I don’t believe the order of execution for Queueable Apex is defined. They “will be processed when system resources become available” (Source). The AsyncApexJob records that represent the queued jobs don’t have a concept of ordering (other than the created date).

Instead you should use chaining, which is defend in the docs as:

If you need to run a job after some other processing is done first by another job, you can chain queueable jobs.


The Apex Flex Queue for batch jobs is something different again. It does however have the concept of reordering.

Attribution
Source : Link , Question Author : dzh , Answer Author : Daniel Ballinger

Leave a Comment