Can I create resque queues on the fly

I am creating a multi-user postgres environment. So client A has schema_1, B has schema_2 ect ..

Now I don’t know all the clients that I have, so I have a simple little task to create a new scheme based on the data in the Tenant's table. Everything is perfectly dynamic: to add a new client, add a new tenant and rake the tenant: db: migrate .. tada all the tables are there, and the client has his own small world. (An unknown cust list, but small, so rake during registration is not a problem)

All is good ...
Except for background jobs.
I want to have a different queue for each client.

http://blog.kabisa.nl/2010/03/16/dynamic-queue-assignment-for-resque-jobs/ still uses hard-coded queues. He can choose between the two that you knew about when you wrote the code, but they are still not very dynamic. Not really.

So my question. I have the line "tenant_1" describing the world of my clients.
How can I use this line to create a queue that contains jobs only for "him".
How to create real dynamic queues?

+5
source share
2 answers

Resque :: Job.create ("client # {client_id}", MyWorker, 3);

It works for us.

+4
source

If anyone comes across this question like me, I found the answer inside the source.

Resque version 1.x(stable) /lib/resque.rb , Job Resque.

 # This method is considered part of the `stable` API.
  def enqueue_to(queue, klass, *args)

, .

Resque.enqueue_to(:my_queue, MyWorker, :my_argument)
+8

All Articles