Fusonic.Extensions.Hangfire 8.1.3

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Fusonic.Extensions.Hangfire --version 8.1.3
NuGet\Install-Package Fusonic.Extensions.Hangfire -Version 8.1.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Fusonic.Extensions.Hangfire" Version="8.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Fusonic.Extensions.Hangfire --version 8.1.3
#r "nuget: Fusonic.Extensions.Hangfire, 8.1.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Fusonic.Extensions.Hangfire as a Cake Addin
#addin nuget:?package=Fusonic.Extensions.Hangfire&version=8.1.3

// Install Fusonic.Extensions.Hangfire as a Cake Tool
#tool nuget:?package=Fusonic.Extensions.Hangfire&version=8.1.3

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0.0-preview.1 58 4/5/2024
8.1.3 123 3/27/2024
8.1.2 76 3/27/2024
8.1.1 135 3/1/2024
8.1.0 205 1/26/2024
8.0.1 251 12/18/2023
8.0.1-rc.2 65 12/7/2023
8.0.1-rc.1 61 12/6/2023
8.0.0 489 11/21/2023
8.0.0-preview1 88 10/4/2023
7.4.0 85 1/25/2024
7.3.0 173 10/11/2023
7.2.1-rc.1 85 8/28/2023
7.2.0 489 6/28/2023
7.2.0-alpha.1 80 6/27/2023
7.1.2 415 5/25/2023
7.1.1 866 4/3/2023
7.1.1-rc.2 81 3/30/2023
7.1.1-rc.1 75 3/30/2023
7.1.0 782 2/28/2023
7.1.0-rc.1 86 2/20/2023
7.0.4-rc.5 88 2/23/2023
7.0.4-rc.4 85 2/23/2023
7.0.4-rc.3 85 2/23/2023
7.0.4-rc.2 85 2/22/2023
7.0.4-rc.1 90 2/16/2023
7.0.3 388 2/16/2023
7.0.2 271 2/9/2023
7.0.2-rc.1 98 2/2/2023
7.0.1 716 1/26/2023
7.0.0 328 1/24/2023
7.0.0-preview1 139 7/18/2022
7.0.0-beta.9 104 1/24/2023
7.0.0-beta.8 92 1/23/2023
7.0.0-beta.7 93 1/23/2023
7.0.0-beta.6 91 1/23/2023
7.0.0-beta.5 99 1/23/2023
7.0.0-beta.4 100 1/19/2023
7.0.0-beta.3 90 1/17/2023
7.0.0-beta.2 95 1/11/2023
7.0.0-beta.1 81 11/24/2022
6.2.2 14,912 9/20/2022
6.2.2-rc.1 115 9/19/2022
6.2.1 3,802 5/4/2022
6.2.0 520 4/21/2022
6.2.0-rc.2 124 4/21/2022
6.2.0-rc.1 124 4/20/2022
6.1.1 916 3/1/2022
6.1.0 588 2/10/2022
6.1.0-rc.3 115 2/10/2022
6.1.0-rc.2 116 2/10/2022
6.1.0-rc.1 122 2/9/2022
6.0.3 1,475 1/18/2022
6.0.2 2,604 1/10/2022
6.0.1 278 12/16/2021
6.0.0 601 12/13/2021
6.0.0-rc.6 146 12/6/2021
6.0.0-rc.5 334 12/6/2021
6.0.0-rc.4 480 12/6/2021
6.0.0-rc.3 378 12/6/2021
6.0.0-rc.2 351 12/6/2021
6.0.0-rc.1 629 11/15/2021
5.4.0 859 10/13/2021
5.3.0 491 9/23/2021
5.3.0-rc.1 335 9/17/2021
5.2.0 3,248 5/20/2021
5.2.0-rcjh.6 190 5/19/2021
5.2.0-rcjh.5 143 5/19/2021
5.2.0-rcjh.4 165 5/19/2021
5.2.0-rcjh.3 147 5/19/2021
5.2.0-rcjh.2 130 4/12/2021
5.2.0-rcjh.1 137 4/12/2021
5.1.3 342 5/19/2021
5.1.2 13,855 3/26/2021
5.1.1 1,021 1/13/2021
5.1.0 2,036 12/16/2020
5.0.0 2,465 11/17/2020
5.0.0-rc.1 273 10/15/2020
4.2.1 18,790 10/8/2020
4.2.0 7,371 8/25/2020
4.1.0 639 8/19/2020
4.0.2 476 8/19/2020
4.0.1 3,747 7/3/2020
4.0.0 491 6/17/2020
3.1.0 481 6/15/2020
3.0.0 9,979 2/4/2020
2.0.0 3,856 9/25/2019
1.0.2 5,055 6/24/2019