Consider a Rails app using Active Job with Sidekiq as the backend. If you schedule a job with MyJob.set(wait: 5.minutes).perform_later, what will happen?
class MyJob < ApplicationJob queue_as :default def perform puts "Job executed" end end MyJob.set(wait: 5.minutes).perform_later
Think about how Active Job and Sidekiq handle delayed execution.
Using set(wait: 5.minutes) schedules the job to be enqueued in Sidekiq after 5 minutes. Sidekiq then executes the job asynchronously.
You want to run a rake task every day at 2am using the 'whenever' gem. Which syntax in schedule.rb is correct?
Check the symbol and time format used by 'whenever' for scheduling.
The 'whenever' gem uses symbols like :day and time strings like '2:00 am' for scheduling.
Given this Sidekiq scheduled job code, why might the job never execute in production?
class CleanupJob < ApplicationJob queue_as :default def perform # cleanup logic end end # Scheduling the job CleanupJob.set(wait_until: Time.now + 1.hour).perform_later
Check if the background worker process is active in production.
If Sidekiq is not running, scheduled jobs remain in Redis but are never executed.
In a Rails app using Active Job with Sidekiq, what is the state of the job immediately after calling MyJob.set(wait: 10.minutes).perform_later?
class MyJob < ApplicationJob def perform puts "Running job" end end MyJob.set(wait: 10.minutes).perform_later
Think about how Sidekiq handles delayed jobs internally.
Sidekiq stores delayed jobs in a scheduled set and only moves them to the queue when the delay expires.
You want to schedule a job to run once at a specific time, and ensure it does not run multiple times if the server restarts or the job is retried. Which approach is best?
Consider how to prevent duplicate jobs in distributed systems.
Using a database-backed scheduler with unique job constraints ensures exactly-once execution even if the server restarts or retries happen.