alexdemers/csharp-resque — pull request #3 by sachinmaharjan (2013-11-08 01:45:48+00:00)
Title: Dynamic queues

Currently, when new queues are added to Redis, workers listening to all queues ('*') do not see the new queues without a restart. This change will refresh the list of queues when polling for jobs.

Here's a small sample app demonstrating the dynamic fetching of queues.
```csharp
using System;
using System.Threading;
using Newtonsoft.Json.Linq;

namespace ResqueTest
{
class MyJob : Resque.Jobs.BaseJob
{
public override void Perform()
{
Console.WriteLine("EXECUTING MyJob");
}
}

class Program
{
static void Main(string[] args)
{
Resque.Resque.SetRedis();
Resque.Resque.AddJob("MyJob", typeof(MyJob));

Resque.Resque.Enqueue("fooqueue", "MyJob", new JObject());
var worker = new Resque.Worker("*");
Thread thread = new Thread(() => worker.Work(5));
thread.Start();

Thread.Sleep(5000);
Resque.Resque.Enqueue("barbqueue", "MyJob", new JObject());
Thread.Sleep(5000);
worker.Shutdown();
thread.Join();
Console.ReadLine();
}
}
}
```

Output:

```
[1/1/0001 12:00:00 AM] Checking fooqueue
[1/1/0001 12:00:00 AM] Found job on fooqueue
[1/1/0001 12:00:00 AM] Checking fooqueue
[1/1/0001 12:00:00 AM] Got fooqueue
EXECUTING MyJob
[1/1/0001 12:00:00 AM] Done (Job{fooqueue}|ID: 4ae71336e44bf9bf79d2752e234818a5|MyJob|[{}])
[1/1/0001 12:00:00 AM] Checking fooqueue
[1/1/0001 12:00:00 AM] Sleeping for 1000
[1/1/0001 12:00:00 AM] Checking fooqueue
[1/1/0001 12:00:00 AM] Sleeping for 1000
[1/1/0001 12:00:00 AM] Checking fooqueue
[1/1/0001 12:00:00 AM] Sleeping for 1000
[1/1/0001 12:00:00 AM] Checking fooqueue
[1/1/0001 12:00:00 AM] Sleeping for 1000
[1/1/0001 12:00:00 AM] Checking fooqueue
[1/1/0001 12:00:00 AM] Sleeping for 1000
[1/1/0001 12:00:00 AM] Checking barbqueue
[1/1/0001 12:00:00 AM] Found job on barbqueue
[1/1/0001 12:00:00 AM] Checking barbqueue
[1/1/0001 12:00:00 AM] Checking fooqueue
[1/1/0001 12:00:00 AM] Got barbqueue
EXECUTING MyJob
[1/1/0001 12:00:00 AM] Done (Job{barbqueue}|ID: 4ae71336e44bf9bf79d2752e234818a5|MyJob|[{}])
[1/1/0001 12:00:00 AM] Checking barbqueue
[1/1/0001 12:00:00 AM] Checking fooqueue
[1/1/0001 12:00:00 AM] Sleeping for 1000
[1/1/0001 12:00:00 AM] Checking barbqueue
[1/1/0001 12:00:00 AM] Checking fooqueue
[1/1/0001 12:00:00 AM] Sleeping for 1000
[1/1/0001 12:00:00 AM] Checking barbqueue
[1/1/0001 12:00:00 AM] Checking fooqueue
[1/1/0001 12:00:00 AM] Sleeping for 1000
[1/1/0001 12:00:00 AM] Checking barbqueue
[1/1/0001 12:00:00 AM] Checking fooqueue
[1/1/0001 12:00:00 AM] Sleeping for 1000
[1/1/0001 12:00:00 AM] Checking barbqueue
[1/1/0001 12:00:00 AM] Checking fooqueue
[1/1/0001 12:00:00 AM] Sleeping for 1000
[1/1/0001 12:00:00 AM] Exiting.
```