Skip to content

Commit

Permalink
Implements IWriteOnlyTransaction.RemoveFromQueue([NotNull] IFetchedJo…
Browse files Browse the repository at this point in the history
…b fetchedJob). Seems to to address #153 but further investigatios needed.
  • Loading branch information
Marco Casamento committed Jun 18, 2024
1 parent 395ff85 commit e391eae
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PackageId>Hangfire.Redis.StackExchange</PackageId>
<IsPackable>true</IsPackable>
<Version>1.10.0</Version>
<PackageVersion>1.10.0</PackageVersion>
<PackageVersion>1.10.1-beta</PackageVersion>
<Authors>Marco Casamento and contributors</Authors>
<Product>Hangfire Redis Storage</Product>
<PackageProjectUrl>https://github.com/marcoCasamento/Hangfire.Redis.StackExchange</PackageProjectUrl>
Expand All @@ -21,6 +21,8 @@
It also supports Batches (Pro Feature)
</Summary>
<PackageReleaseNotes>
1.10.1-Beta1
- Fix #153 Appeared after 1.10.0 release. Only updates to this version for testing purposes and PLEASE report any issues. Stick to 1.9.3 for production.
1.10.0
- Fix #135 -CHANGED BEHAVIOR- Library now requeue jobs from dead server (read comments in the issue) thanks to @Lexy2
- Implement #150 (Replace async Redis calls with sync ones) thanks to @Lexy2
Expand Down
4 changes: 2 additions & 2 deletions Hangfire.Redis.StackExchange/RedisFetchedJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public void Requeue()
_redis.ListRightPushAsync(_storage.GetRedisKey($"queue:{Queue}"), JobId);
if (fetchedAt == FetchedAt)
{
_redis.ListRemoveAsync(_storage.GetRedisKey($"queue:{Queue}:dequeued"), JobId, -1);
_redis.HashDeleteAsync(_storage.GetRedisKey($"job:{JobId}"), new RedisValue[] { "Fetched", "Checked" });
_redis.ListRemove(_storage.GetRedisKey($"queue:{Queue}:dequeued"), JobId, -1);
_redis.HashDelete(_storage.GetRedisKey($"job:{JobId}"), new RedisValue[] { "Fetched", "Checked" });
}

_redis.Publish(_storage.SubscriptionChannel, JobId); }
Expand Down
7 changes: 4 additions & 3 deletions Hangfire.Redis.StackExchange/RedisStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public class RedisStorage : JobStorage
{ JobStorageFeatures.Transaction.AcquireDistributedLock, true },
{ JobStorageFeatures.Transaction.CreateJob, true }, // overridden in constructor
{ JobStorageFeatures.Transaction.SetJobParameter, true}, // overridden in constructor
{ JobStorageFeatures.Transaction.RemoveFromQueue(typeof(RedisFetchedJob)), true }, // overridden in constructor { JobStorageFeatures.Monitoring.DeletedStateGraphs, true },
{ JobStorageFeatures.Transaction.RemoveFromQueue(typeof(RedisFetchedJob)), true }, // overridden in constructor
{ JobStorageFeatures.Monitoring.DeletedStateGraphs, true },
{ JobStorageFeatures.Monitoring.AwaitingJobs, true }
};

Expand Down Expand Up @@ -90,8 +91,8 @@ private RedisStorage(string connectionString, IConnectionMultiplexer connectionM

private void SetTransactionalFeatures()
{
_features[JobStorageFeatures.Transaction.CreateJob] = _options.UseTransactions;
_features[JobStorageFeatures.Transaction.SetJobParameter] = _options.UseTransactions;
_features[JobStorageFeatures.Transaction.CreateJob] = _options.UseTransactions;
_features[JobStorageFeatures.Transaction.SetJobParameter] = _options.UseTransactions;
_features[JobStorageFeatures.Transaction.RemoveFromQueue(typeof(RedisFetchedJob))] = _options.UseTransactions;
}

Expand Down
4 changes: 4 additions & 0 deletions Hangfire.Redis.StackExchange/RedisWriteOnlyTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ public override void RemoveHash([NotNull] string key)
_transaction.KeyDeleteAsync(_storage.GetRedisKey(key));
}

public override void RemoveFromQueue([NotNull] IFetchedJob fetchedJob)
{
fetchedJob.RemoveFromQueue();
}
public override void Dispose()
{
//Don't have to dispose anything
Expand Down

0 comments on commit e391eae

Please sign in to comment.