2014-08-27T16:41:28-07:00http://xavier-perez.com/Octopress2014-05-25T05:00:00-07:00http://xavier-perez.com/blog/2014/05/25/enqueuing-sidekiq-job-without-sidekiqLet’s say you have a running Sidekiq system and for whatever reason you need to enqueue
jobs from another not ruby-based environment or system. It’s actually quite simple as you
can directly push your jobs into Redis without the Sidekiq gem.

Now for simple jobs (as opposed to scheduled jobs), Sidekiq use two different keys: a list and a set. The set called queues by default only store the queues names. The list named queue:nameofthequeue actually store the job informations. Let’s have a closer look:

The score is actually the time at which the job is supposed to be executed! This allow Sidekiq to use ZRANGEBYSCORE to simply pop the jobs that should be executed 1. Now if you want to enqueue a scheduled job, you just have to add it to the schedule sorted set using ZADD!

And really, that’s all there is to it! As long as you know the worker’s class name and the arguments it takes, you can enqueue jobs from any programming language. Or even directly inside Redis if you wish so!