Events versus Queues
Start with what needs to happen. Saving a photo is a fact other features can observe. Checking a saved photo is a unit of work a worker can perform. Checking the saved photo count every day is a schedule.
Default Recommendation
| Need | Use | Photo example |
|---|---|---|
| Announce a fact to subscribers | Event | Publish photos.saved after the record is written |
| Execute work with a worker, timeout, or retry | Job | Queue photos:check with a saved photo ID |
| Start work at recurring times | Schedule | Run photos:audit at a set interval |
Events
A typed event belongs to the feature that publishes it. It can have several subscribers, each reacting independently. Use Event Subscribers to add a reaction through the App's registration.
Queues and Jobs
A job carries work for a registered handler. Keep the payload small, such as the photo ID in Run a Photo Job, so the worker can load the current record. The generated queue manager selects the requested backend and make:job registers the handler with the App.
How They Work Together
After a successful database write, publish a fact if other features need to hear about it. A subscriber can turn one reaction into its own queued job. For example, a photo subscriber can pass the saved ID to a worker that checks the record. The event identifies the fact and the job carries the work.
When a database commit and follow-up delivery must succeed as one durable workflow, use the outbox design to record pending deliveries in the same transaction.
Scheduler
A schedule starts work at a time or interval. It can call a service for a short read or enqueue a job for work that needs worker capacity or retries. Give the schedule its own name so operators can see when it ran.
Driver Support
Use inproc events and the workerpool queue in a combined local App. If HTTP and workers run in separate processes, choose a shared queue backend. Choose a transport-backed event bus when the subscribers must run in other processes. See Driver Selection for build support and configuration.
Operational Differences
The backend determines persistence, delivery, and retry behavior. A job must use a durable backend to survive a process restart. A subscriber should handle repeated messages when its transport can redeliver them. A scheduler needs singleton operation or shared locking when runs across replicas can overlap.
Next Steps
- Events publishes
photos.savedfrom the existing photo feature. - Run a Photo Job shows dispatch and retry with a local worker.
- Task Scheduling adds a recurring task to the same App.