Skip to main content

Posts

Scheduled Apex

Explore practical guides and implementation patterns for this topic.

Master Salesforce Scheduled Apex & The Flex Queue
Salesforce Basics

Master Salesforce Scheduled Apex & The Flex Queue

๐Ÿ’ฌ In plain words: Scheduled Apex acts as your org's cron job: "Run this class every night at 2 AM." The Apex Flex Queue is the waiting room for these jobs. Because Salesforce only allows 5 batch jobs to run concurrently, up to 100 additional jobs can sit patiently in the Flex Queue until a slot opens up. You schedule the class, and the platform handles the waiting room. ๐Ÿ“Œ The 2 AM Reminder Example: You need to send subscription renewal reminders daily at 2:00 AM. You write a Schedulable class and set a cron expression: 0 0 2 * * ? . When 2:00 AM hits, what if 9 other heavy batch jobs are already running? No problem. Your reminder job enters the Flex Queue (which holds up to 100 jobs) and waits until one of the 5 active slots becomes available. ๐Ÿง  Memory Aid: The Alarm Clock + The Waiting Room Scheduled Apex is the alarm clock . The Flex Queue is the waiting room (100 seats, 5 doors). Core Concept: How Scheduled Ap...