![]() |
VOOZH | about |
dotnet add package Hangfire.Azure.ServiceBusQueue --version 6.0.0
NuGet\Install-Package Hangfire.Azure.ServiceBusQueue -Version 6.0.0
<PackageReference Include="Hangfire.Azure.ServiceBusQueue" Version="6.0.0" />
<PackageVersion Include="Hangfire.Azure.ServiceBusQueue" Version="6.0.0" />Directory.Packages.props
<PackageReference Include="Hangfire.Azure.ServiceBusQueue" />Project file
paket add Hangfire.Azure.ServiceBusQueue --version 6.0.0
#r "nuget: Hangfire.Azure.ServiceBusQueue, 6.0.0"
#:package Hangfire.Azure.ServiceBusQueue@6.0.0
#addin nuget:?package=Hangfire.Azure.ServiceBusQueue&version=6.0.0Install as a Cake Addin
#tool nuget:?package=Hangfire.Azure.ServiceBusQueue&version=6.0.0Install as a Cake Tool
👁 Official Site
👁 Latest version
👁 Build status
👁 License MIT
Adds support for using Azure Service Bus Queues with Hangfire's SQL storage provider to reduce latency and remove the need to poll the database for new jobs.
All job data continues to be stored and maintained within SQL storage, but polling is removed in favour of pushing the job ids through the service bus.
Hangfire.Azure.ServiceBusQueue is available as a NuGet package. Install it using the NuGet Package Console window:
PM> Install-Package Hangfire.Azure.ServiceBusQueue
Hangfire v1.7+ introduced breaking changes to the SQL Server integration points and requires at least version 4.0.0 of this library. If you are on an older version of Hangfire please use a lower version of Hangfire.Azure.ServiceBusQueue
To use the queue it needs to be added to your existing SQL Server storage configuration.
For .NETCore and beyond, you can use the IGlobalConfiguration extension .UseServiceBusQueues:
//You can use .UseServiceBusQueues only after .UseSqlStorage()
// Uses default options (no prefix or configuration) with the "default" queue only
services.AddHangfire(configuration => configuration
.UseSqlServerStorage("<sql connection string>")
.UseServiceBusQueues("<azure servicebus connection string>")
// Uses default options (no prefix or configuration) with the "critical" and "default" queues
services.AddHangfire(configuration => configuration
.UseSqlServerStorage("<sql connection string>")
.UseServiceBusQueues("<azure servicebus connection string>", "critical", "default")
// Configures queues on creation and uses the "crtical" and "default" queues
services.AddHangfire(configuration => configuration
.UseSqlServerStorage("<sql connection string>")
.UseServiceBusQueues("<azure servicebus connection string>",
queueOptions => {
queueOptions.MaxSizeInMegabytes = 5120;
queueOptions.DefaultMessageTimeToLive = new TimeSpan(0, 1, 0);
} "critical", "default")
// Specifies all options
services.AddHangfire(configuration => configuration
.UseSqlServerStorage("<sql connection string>")
.UseServiceBusQueues(new ServiceBusQueueOptions
{
ConnectionString = connectionString,
Configure = configureAction,
// The actual queues used in Azure will have this prefix if specified
// (e.g. the "default" queue will be created as "my-prefix-default")
//
// This can be useful in development environments particularly where the machine
// name could be used to separate individual developers machines automatically
// (i.e. "my-prefix-{machine-name}".Replace("{machine-name}", Environment.MachineName))
QueuePrefix = "my-prefix-",
// The queues to monitor. This *must* be specified, even to set just
// the default queue as done here
Queues = new [] { EnqueuedState.DefaultQueue },
// By default queues will be checked and created on startup. This option
// can be disabled if the application will only be sending / listening to
// the queue and you want to remove the 'Manage' permission from the shared
// access policy.
//
// Note that the dashboard *must* have the 'Manage' permission otherwise the
// queue length cannot be read
CheckAndCreateQueues = false,
// Typically a lower value is desired to keep the throughput of message processing high. A lower timeout means more calls to
// Azure Service Bus which can increase costs, especially on an under-utilised server with few jobs.
// Use a Higher value for lower costs in non production or non critical jobs
LoopReceiveTimeout = TimeSpan.FromMilliseconds(500)
// Delay between queue polling requests
QueuePollInterval = TimeSpan.Zero
}));
You can also use UseServiceBusQueues overloads:
var sqlStorage = new SqlServerStorage("<connection string>");
// The connection string *must* be for the root namespace and have the "Manage"
// permission if used by the dashboard
var connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
// You can configure queues on first creation using this action
Action<QueueDescription> configureAction = qd =>
{
qd.MaxSizeInMegabytes = 5120;
qd.DefaultMessageTimeToLive = new TimeSpan(0, 1, 0);
};
// Uses default options (no prefix or configuration) with the "default" queue only
sqlStorage.UseServiceBusQueues(connectionString);
// Uses default options (no prefix or configuration) with the "critical" and "default" queues
sqlStorage.UseServiceBusQueues(connectionString, "critical", "default");
// Configures queues on creation and uses the "crtical" and "default" queues
sqlStorage.UseServiceBusQueues(connectionString, configureAction, "critical", "default");
// Specifies all options
sqlStorage.UseServiceBusQueues(new ServiceBusQueueOptions
{
ConnectionString = connectionString,
Credential = new DefaultAzureCredential() // any Azure.Identity.TokenCredential
Configure = configureAction,
// The actual queues used in Azure will have this prefix if specified
// (e.g. the "default" queue will be created as "my-prefix-default")
//
// This can be useful in development environments particularly where the machine
// name could be used to separate individual developers machines automatically
// (i.e. "my-prefix-{machine-name}".Replace("{machine-name}", Environment.MachineName))
QueuePrefix = "my-prefix-",
// The queues to monitor. This *must* be specified, even to set just
// the default queue as done here
Queues = new [] { EnqueuedState.DefaultQueue },
// By default queues will be checked and created on startup. This option
// can be disabled if the application will only be sending / listening to
// the queue and you want to remove the 'Manage' permission from the shared
// access policy.
//
// Note that the dashboard *must* have the 'Manage' permission otherwise the
// queue length cannot be read
CheckAndCreateQueues = false,
// Typically a lower value is desired to keep the throughput of message processing high. A lower timeout means more calls to
// Azure Service Bus which can increase costs, especially on an under-utilised server with few jobs.
// Use a Higher value for lower costs in non production or non critical jobs
LoopReceiveTimeout = TimeSpan.FromMilliseconds(500)
// Delay between queue polling requests
QueuePollInterval = TimeSpan.Zero
});
GlobalConfiguration.Configuration
.UseStorage(sqlStorage);
Open-source project are developing more smoothly, when all discussions are held in public.
If you have any questions or problems related to Hangfire itself or this queue implementation or want to discuss new features, please visit the discussion forum. You can sign in there using your existing Google or GitHub account, so it's very simple to start using it.
If you've discovered a bug, please report it to the Hangfire GitHub Issues. Detailed reports with stack traces, actual and expected behavours are welcome.
Hangfire.Azure.ServiceBusQueues is released under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 is compatible. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 6.0.0 | 16,938 | 4/14/2025 |
| 5.0.0 | 93,741 | 10/5/2021 |
| 4.1.0 | 206,020 | 5/11/2019 |
| 4.0.0 | 1,526 | 4/9/2019 |
| 3.0.1 | 8,461 | 11/7/2018 |
| 3.0.0 | 4,901 | 10/29/2018 |
| 2.2.2 | 2,724 | 5/1/2019 |
| 2.2.1 | 32,635 | 8/25/2017 |
| 2.2.0 | 24,107 | 3/28/2017 |
| 2.1.1 | 39,065 | 3/18/2016 |
| 2.1.0 | 2,010 | 3/18/2016 |
| 2.0.0 | 2,828 | 11/5/2015 |
| 1.0.0 | 2,266 | 9/22/2015 |
| 0.0.1 | 2,537 | 5/17/2014 |