odinserj/HangFire — pull request #85 by odinserj (2014-05-11 12:00:09+00:00)
Title: SQL Server + MSMQ Storage Implementation

SQL Server job storage implementation does not require you to learn and install additional technologies, such as Redis, for projects to use HangFire. However, it uses polling to get new jobs that *increases latency* between the creation and invocation process (see also #52).

This MSMQ implementation replaces only the way HangFire enqueues and dequeues jobs. It uses transactional queues to delete jobs only upon successful completion, that allows reliable job processing inside ASP.NET applications. MSMQ queues contain only job identifiers, other information is still persisted in the SQL Server database.

**Advantages of using MSMQ**

* **No additional latency**. It uses blocking calls to fetch jobs – they will be processed as soon as possible.
* **Immediate re-queueing of terminated jobs**. If the processing was terminated in the middle, it will be started again immediately after application restart. SQL Server implementation uses InvisibleTimeout to distinguish between long-running and aborted jobs.

**Usage**

To use MSMQ queues, you should do the following steps:

1. Create them manually on each host.
2. Pass the `MessageQueuePathPattern` option for your `SqlServerStorage` constructor that contains the queue path pattern that will be used to resolve actual paths based on the given queue name.

```csharp
var options = new SqlServerStorageOptions
{
MessageQueuePathPattern = @".\Private$\hangfire-{0}"
};

JobStorage.Current = new SqlServerStorage("", options);
```

To see the full list of supported paths and queues, check the [MSDN article](http://msdn.microsoft.com/en-us/library/e9d4k4ze.aspx).

**Implementation is still in progress**

* [ ] Monitoring API implementation for MSMQ queues
* [ ] Automatic integration tests

Unfortunately I'm not an expert on MSMQ. I used it only for the simplest cases and can skip some important things. If you are familiar with this technology, can you review the code and give some useful advises?