⚡ Background Job Example
Demonstrates background job processing with Falcon and ActiveJob integration. Shows how Falcon efficiently handles background job queuing while maintaining excellent performance for web requests.
🎯 Try Background Jobs
Submit a job to see real-time background processing in action. Job results will appear in the table below automatically (make sure the job server is running!)
📊 Job Execution History
Live updates powered by Turbo Streams - new job executions appear automatically:
| ID | Job Name | Data | Created At |
|---|---|---|---|
| 1 | MyJob | {"arguments" => [], "queued_to" => "default", "delay" => 0} | 2026-01-21 10:03:28 UTC |
| 2 | MyJob | {"arguments" => [], "queued_to" => "default", "delay" => 2} | 2026-01-21 10:03:33 UTC |
| 3 | MyJob | {"arguments" => [], "queued_to" => "local", "delay" => 2} | 2026-01-21 10:03:39 UTC |
| 4 | MyJob | {"arguments" => [], "queued_to" => "default", "delay" => 0} | 2026-01-22 08:16:13 UTC |
| 5 | MyJob | {"arguments" => [], "queued_to" => "default", "delay" => 1} | 2026-01-22 08:16:26 UTC |
| 6 | MyJob | {"arguments" => [], "queued_to" => "default", "delay" => 0} | 2026-01-22 08:40:14 UTC |
| 7 | MyJob | {"arguments" => [], "queued_to" => "default", "delay" => 1} | 2026-01-22 09:09:41 UTC |
| 8 | MyJob | {"arguments" => [], "queued_to" => "default", "delay" => 2} | 2026-01-22 09:10:51 UTC |
| 9 | MyJob | {"arguments" => [], "queued_to" => "default", "delay" => 0} | 2026-01-22 09:35:48 UTC |
| 10 | MyJob | {"arguments" => [], "queued_to" => "default", "delay" => 0} | 2026-01-22 09:35:54 UTC |
| 11 | MyJob | {"arguments" => [], "queued_to" => "default", "delay" => 0} | 2026-01-22 10:15:11 UTC |
🔧 Technical Implementation
- ActiveJob Integration: Standard Rails ActiveJob framework.
- Async Job Adapter: Uses async-job gem for high-performance job processing.
- Multiple Queues: Support for different queue priorities and types.
- Real-time Updates: Turbo Stream integration for live job execution tracking.
- Persistent Storage: Job execution records stored in database.
📋 Key Files
app/controllers/job_controller.rb- JobController - Job submission and monitoringapp/jobs/my_job.rb- MyJob - Background job implementationapp/models/job_execution.rb- JobExecution - Job tracking modelconfig/initializers/async_job.rb- async_job.rb - Job queue configuration
🚀 Performance Benefits
Traditional Ruby web servers can struggle when job processing blocks request handling. Falcon's async architecture allows seamless integration between web requests and background job processing, maintaining responsive web performance even under heavy job loads.
⚙️ Setup Requirements
- Redis Server: Must be running on localhost for job queuing.
- Job Server: Run
bundle exec async-job-adapter-active_job-serverto process jobs. - Database: Job executions are tracked in the database.