Question

I have a 'main' rails app that needs to offload some work to some named delayed-job queues. I'd like to keep all the logic for processing those jobs in a separate app, which would run on a separate server from the main web app servers. It would connect to the same database, but only have a small fraction of the models defined, just what it will need to process these jobs.

When I queue up a job, is there any way to ONLY queue up the id of the record to act on? Combined with the queue name, I think that should be enough for the worker to know what to do. Or, if a class needs to be provided, can I have a dummy stripped down version of the class in the main app, with the actual implementation logic in a version of the class in the separate 'worker' app?

Was it helpful?

Solution

Actually, what you're describing above is correct: You want to queue an id, and sometimes other required information to identify the record you want to pull from the database, and NOT an object, especially if it's an ActiveRecord::Base object.

Queuing an object is problematic and can lead to issues. Check my answer at:

https://stackoverflow.com/a/21751030/226255

You can test if your second application is pulling correctly by doing the following in console: (make sure to push a Delayed::Job to queue first)

Delayed::Job.first.invoke_job
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top