private void ProcessQueue(string queue, RedisConnection connection) { // Allowing only one server at a time to process the timed out // jobs from the specified queue. Logger.DebugFormat("Acquiring the lock for the fetched list of the '{0}' queue...", queue); using (var Lock = new RedisLock(connection.Redis, String.Format(_options.Prefix + "queue:{0}:dequeued:lock", queue), Guid.NewGuid().ToString(), _options.FetchedLockTimeout)) { Logger.DebugFormat("Looking for timed out jobs in the '{0}' queue...", queue); var jobIds = connection.Redis.ListRange(String.Format(_options.Prefix + "queue:{0}:dequeued", queue)); var requeued = 0; foreach (var jobId in jobIds) { if (RequeueJobIfTimedOut(connection, jobId, queue)) { requeued++; } } if (requeued == 0) { Logger.DebugFormat("No timed out jobs were found in the '{0}' queue", queue); } else { Logger.InfoFormat( "{0} timed out jobs were found in the '{1}' queue and re-queued.", requeued, queue); } } }
private void ProcessQueue(string queue, RedisConnection connection) { // Allowing only one server at a time to process the timed out // jobs from the specified queue. Logger.DebugFormat("Acquiring the lock for the fetched list of the '{0}' queue...", queue); using (var Lock = new RedisLock(connection.Redis, String.Format(_options.Prefix + "queue:{0}:dequeued:lock", queue), Guid.NewGuid().ToString(), _options.FetchedLockTimeout)) { Logger.DebugFormat("Looking for timed out jobs in the '{0}' queue...", queue); var jobIds = connection.Redis.ListRange(String.Format(_options.Prefix + "queue:{0}:dequeued", queue)); var requeued = 0; foreach (var jobId in jobIds) { if (RequeueJobIfTimedOut(connection, jobId, queue)) { requeued++; } } if (requeued == 0) { Logger.DebugFormat("No timed out jobs were found in the '{0}' queue", queue); } else { connection.Sub.AnnounceJob(); Logger.InfoFormat( "{0} timed out jobs were found in the '{1}' queue and re-queued.", requeued, queue); } } }