Reddoxx.Quartz.MongoDbJobStore
1.1.4
Prefix Reserved
See the version list below for details.
dotnet add package Reddoxx.Quartz.MongoDbJobStore --version 1.1.4
NuGet\Install-Package Reddoxx.Quartz.MongoDbJobStore -Version 1.1.4
<PackageReference Include="Reddoxx.Quartz.MongoDbJobStore" Version="1.1.4" />
paket add Reddoxx.Quartz.MongoDbJobStore --version 1.1.4
#r "nuget: Reddoxx.Quartz.MongoDbJobStore, 1.1.4"
// Install Reddoxx.Quartz.MongoDbJobStore as a Cake Addin #addin nuget:?package=Reddoxx.Quartz.MongoDbJobStore&version=1.1.4 // Install Reddoxx.Quartz.MongoDbJobStore as a Cake Tool #tool nuget:?package=Reddoxx.Quartz.MongoDbJobStore&version=1.1.4
MongoDB Job Store for Quartz.NET
Fork of the awesome codebase of @glucaci with multiple tweaks:
- Latest .net support
- Quartz cluster support
- DI-based configuration
Limitations
- Due to the nature of the DI-based approach multiple schedulers are not supported on the same host (
SchedulerBuilder.Build()
). - The locking mechanism has been rebuilt to use a
SELECT FOR UPDATE
approach, which requires transactions. So your MongoDb needs to run in a replica-set configuration.
Nuget
Install-Package Reddoxx.Quartz.MongoDbJobStore
Basic Usage
First, create your own QuartzMongoDbJobStoreFactory
, which provides the a database-instance where your collection should be stored in.
The JobStoreFactory itself also needs to be added to your DI-Container as it'll be resolved by the MongoDbJobStore
later on.
internal class QuartzMongoDbJobStoreFactory : IQuartzMongoDbJobStoreFactory
{
private const string LocalConnectionString = "mongodb://localhost/quartz";
private readonly IMongoDatabase _database;
public QuartzMongoDbJobStoreFactory()
{
var url = new MongoUrl(LocalConnectionString);
var client = new MongoClient(url);
_database = client.GetDatabase(url.DatabaseName);
}
public IMongoDatabase GetDatabase()
{
return _database;
}
}
Next, register your QuartzMongoDbJobStoreFactory
in your DI-Container:
// Make your job store factory available to the MongoDbJobStore
services.AddSingleton<IQuartzMongoDbJobStoreFactory, QuartzMongoDbJobStoreFactory>();
Then we can configure quartz for the host. Be sure to specify MongoDbJobStore
in q.UsePersistentStore<MongoDbJobStore>
as this
registers the MongoDbJobStore
singleton as well. storage.ConfigureMongoDb(c => ...)
allows for further customization.
services.AddQuartz(
q =>
{
q.SchedulerId = "AUTO";
q.UsePersistentStore<MongoDbJobStore>(
storage =>
{
storage.UseClustering();
storage.UseNewtonsoftJsonSerializer();
// Your custom job store configuration
storage.ConfigureMongoDb(
c =>
{
// Configure your custom collection prefix
c.CollectionPrefix = "CustomPrefix";
}
);
}
);
}
);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- JetBrains.Annotations (>= 2023.3.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- MongoDB.Driver (>= 2.23.2)
- Quartz (>= 3.8.1)
- Quartz.Serialization.Json (>= 3.8.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Reddoxx.Quartz.MongoDbJobStore:
Package | Downloads |
---|---|
Reddoxx.Quartz.MongoDbJobStore.Redlock
Redlock locking support for quartz-mongodb-job-store |
GitHub repositories
This package is not used by any popular GitHub repositories.