Fusonic.Extensions.Hangfire
8.0.0
Prefix Reserved
See the version list below for details.
dotnet add package Fusonic.Extensions.Hangfire --version 8.0.0
NuGet\Install-Package Fusonic.Extensions.Hangfire -Version 8.0.0
<PackageReference Include="Fusonic.Extensions.Hangfire" Version="8.0.0" />
paket add Fusonic.Extensions.Hangfire --version 8.0.0
#r "nuget: Fusonic.Extensions.Hangfire, 8.0.0"
// Install Fusonic.Extensions.Hangfire as a Cake Addin #addin nuget:?package=Fusonic.Extensions.Hangfire&version=8.0.0 // Install Fusonic.Extensions.Hangfire as a Cake Tool #tool nuget:?package=Fusonic.Extensions.Hangfire&version=8.0.0
Hangfire
Out-Of-Band Processing of CQRS Command and Event-Handlers
When applying CQRS, it allows us to easily decorate handlers with generic decorators.
By applying the Fusonic.Extensions.Common.OutOfBandAttribute
, you can decorate handlers which are allowed to run outside of the current flow. Whenever this handler gets called, the execution pipeline looks for the attribute on the handler. If the attribute is available, the handler is scheduled for async execution, meaning it runs “out of band” of the current logical flow.
That means that the message will be stored in the outbox as part of the current ACID transaction and so it gets scheduled for async background processing as soon as the current transaction completes.
This way we you can atomically perform your business operation including scheduling commands/events which must be executed afterwards, so that we get into an consistent state.
Registration:
Container.RegisterOutOfBandDecorators();
Container.RegisterDecorator(typeof(IRequestHandler<,>), typeof(TransactionalRequestHandlerDecorator<,>));
If you want to process notifications out of band it is important to call Container.RegisterOutOfBandDecorators()
before you register any other decorator. Otherwise this would cause the NotificationDispatcher
to try to resolve a decorator instead of the actual NotificationHandler
.
Usage:
[OutOfBand]
public class SendEmailCommandHandler : IRequestHandler<SendEmailCommand>
{
...
}
DisableHangfireDashboardAuthorizationFilter
For local development, where you have other means of authorization, you may want to disable the hangfire authorization for the dashboard.
For disabling the local development authorization for local development, you usually just can use the default options. However, those may not work when running the backend in a docker container, as hangfire still filters the requests to "only local requests". To completly disable any authorization use this filter instead.
Usage:
dashboardOptions = new DashboardOptions { Authorization = new[] { new DisableHangfireDashboardAuthorizationFilter() } };
app.UseHangfireDashboard(options: dashboardOptions);
Transactional job processor
If you want all your background jobs to run within a transaction (which is usually the case), you can use the TransactionalJobProcessor
.
Configuration with SimpleInjector:
Container.RegisterSingleton<ITransactionScopeHandler, TransactionScopeHandler>();
// Transaction scope for all request handlers:
Container.RegisterDecorator(typeof(IRequestHandler<,>), typeof(TransactionalCommandHandlerDecorator<,>));
// Transaction scope for all notification handlers:
Container.RegisterDecorator(typeof(INotificationHandler<>), typeof(TransactionalNotificationHandlerDecorator<>));
Using DisplayNameFunc.DisplayNameFunc
OutOfBand jobs are processed via IJobProcessor.ProcessAsync
. As a consequence, each jobs name in hangfires dashboard will be listed as "JobProcessor.ProcessAsync".
Fortunately there is an easy way to enable meaningful job display names:
dashboardOptions.DisplayNameFunc = DashboardHelpers.FormatJobDisplayName;
Once enabled, request handlers type name (without assembly information) will be used as the job display name.
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
- Fusonic.Extensions.Common (>= 8.0.0)
- Fusonic.Extensions.MediatR (>= 8.0.0)
- Hangfire.Core (>= 1.8.6)
- SimpleInjector (>= 5.4.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
9.5.0 | 117 | 10/4/2024 |
9.4.0 | 209 | 9/23/2024 |
9.3.1 | 169 | 9/11/2024 |
9.3.0 | 103 | 9/11/2024 |
9.2.0 | 115 | 8/8/2024 |
9.2.0-rc.3 | 49 | 8/7/2024 |
9.2.0-rc.2 | 34 | 8/5/2024 |
9.2.0-rc.1 | 43 | 8/1/2024 |
9.1.0 | 62 | 7/29/2024 |
9.0.0 | 477 | 7/17/2024 |
9.0.0-preview.2 | 51 | 6/13/2024 |
9.0.0-preview.1 | 67 | 4/5/2024 |
8.1.3 | 206 | 3/27/2024 |
8.1.2 | 100 | 3/27/2024 |
8.1.1 | 159 | 3/1/2024 |
8.1.0 | 272 | 1/26/2024 |
8.0.1 | 345 | 12/18/2023 |
8.0.1-rc.2 | 75 | 12/7/2023 |
8.0.1-rc.1 | 70 | 12/6/2023 |
8.0.0 | 1,157 | 11/21/2023 |
8.0.0-preview1 | 107 | 10/4/2023 |
7.4.0 | 108 | 1/25/2024 |
7.3.0 | 196 | 10/11/2023 |
7.2.1-rc.1 | 94 | 8/28/2023 |
7.2.0 | 514 | 6/28/2023 |
7.2.0-alpha.1 | 91 | 6/27/2023 |
7.1.2 | 436 | 5/25/2023 |
7.1.1 | 893 | 4/3/2023 |
7.1.1-rc.2 | 92 | 3/30/2023 |
7.1.1-rc.1 | 83 | 3/30/2023 |
7.1.0 | 806 | 2/28/2023 |
7.1.0-rc.1 | 97 | 2/20/2023 |
7.0.4-rc.5 | 98 | 2/23/2023 |
7.0.4-rc.4 | 94 | 2/23/2023 |
7.0.4-rc.3 | 95 | 2/23/2023 |
7.0.4-rc.2 | 94 | 2/22/2023 |
7.0.4-rc.1 | 101 | 2/16/2023 |
7.0.3 | 411 | 2/16/2023 |
7.0.2 | 294 | 2/9/2023 |
7.0.2-rc.1 | 110 | 2/2/2023 |
7.0.1 | 736 | 1/26/2023 |
7.0.0 | 349 | 1/24/2023 |
7.0.0-preview1 | 157 | 7/18/2022 |
7.0.0-beta.9 | 112 | 1/24/2023 |
7.0.0-beta.8 | 100 | 1/23/2023 |
7.0.0-beta.7 | 101 | 1/23/2023 |
7.0.0-beta.6 | 100 | 1/23/2023 |
7.0.0-beta.5 | 108 | 1/23/2023 |
7.0.0-beta.4 | 109 | 1/19/2023 |
7.0.0-beta.3 | 99 | 1/17/2023 |
7.0.0-beta.2 | 105 | 1/11/2023 |
7.0.0-beta.1 | 92 | 11/24/2022 |
6.2.2 | 15,009 | 9/20/2022 |
6.2.2-rc.1 | 124 | 9/19/2022 |
6.2.1 | 3,871 | 5/4/2022 |
6.2.0 | 541 | 4/21/2022 |
6.2.0-rc.2 | 136 | 4/21/2022 |
6.2.0-rc.1 | 137 | 4/20/2022 |
6.1.1 | 938 | 3/1/2022 |
6.1.0 | 608 | 2/10/2022 |
6.1.0-rc.3 | 124 | 2/10/2022 |
6.1.0-rc.2 | 123 | 2/10/2022 |
6.1.0-rc.1 | 132 | 2/9/2022 |
6.0.3 | 1,494 | 1/18/2022 |
6.0.2 | 2,622 | 1/10/2022 |
6.0.1 | 288 | 12/16/2021 |
6.0.0 | 619 | 12/13/2021 |
6.0.0-rc.6 | 155 | 12/6/2021 |
6.0.0-rc.5 | 342 | 12/6/2021 |
6.0.0-rc.4 | 491 | 12/6/2021 |
6.0.0-rc.3 | 386 | 12/6/2021 |
6.0.0-rc.2 | 360 | 12/6/2021 |
6.0.0-rc.1 | 637 | 11/15/2021 |
5.4.0 | 880 | 10/13/2021 |
5.3.0 | 511 | 9/23/2021 |
5.3.0-rc.1 | 346 | 9/17/2021 |
5.2.0 | 3,268 | 5/20/2021 |
5.2.0-rcjh.6 | 199 | 5/19/2021 |
5.2.0-rcjh.5 | 153 | 5/19/2021 |
5.2.0-rcjh.4 | 174 | 5/19/2021 |
5.2.0-rcjh.3 | 156 | 5/19/2021 |
5.2.0-rcjh.2 | 141 | 4/12/2021 |
5.2.0-rcjh.1 | 145 | 4/12/2021 |
5.1.3 | 362 | 5/19/2021 |
5.1.2 | 14,285 | 3/26/2021 |
5.1.1 | 1,042 | 1/13/2021 |
5.1.0 | 2,055 | 12/16/2020 |
5.0.0 | 2,486 | 11/17/2020 |
5.0.0-rc.1 | 283 | 10/15/2020 |
4.2.1 | 18,965 | 10/8/2020 |
4.2.0 | 7,392 | 8/25/2020 |
4.1.0 | 659 | 8/19/2020 |
4.0.2 | 496 | 8/19/2020 |
4.0.1 | 3,769 | 7/3/2020 |
4.0.0 | 512 | 6/17/2020 |
3.1.0 | 502 | 6/15/2020 |
3.0.0 | 10,000 | 2/4/2020 |
2.0.0 | 3,878 | 9/25/2019 |
1.0.2 | 5,076 | 6/24/2019 |