Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET Standard2 support and Azure.Messaging.Servicebus SDK #20

Merged
merged 13 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .nuget/NuGet.Config

This file was deleted.

Binary file modified .nuget/NuGet.exe
Binary file not shown.
144 changes: 0 additions & 144 deletions .nuget/NuGet.targets

This file was deleted.

4 changes: 2 additions & 2 deletions .nuget/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="7-Zip.CommandLine" version="9.20.0" />
<package id="Hangfire.Build" version="0.1.3" />
<package id="7-Zip.CommandLine" version="18.1.0" />
<package id="Hangfire.Build" version="0.2.6" />
<package id="psake" version="4.4.1" />
</packages>
Binary file not shown.
22 changes: 4 additions & 18 deletions HangFire.Azure.ServiceBusQueue.sln
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.9
# Visual Studio Version 16
VisualStudioVersion = 16.0.29123.88
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hangfire.Azure.ServiceBusQueue", "src\HangFire.Azure.ServiceBusQueue\Hangfire.Azure.ServiceBusQueue.csproj", "{4CC51F69-0311-4485-B7DE-9ECAB3A1B5E5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hangfire.Azure.ServiceBusQueue", "src\HangFire.Azure.ServiceBusQueue\Hangfire.Azure.ServiceBusQueue.csproj", "{4CC51F69-0311-4485-B7DE-9ECAB3A1B5E5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{756FFE84-4908-42BE-9918-4DA34E85AAFB}"
ProjectSection(SolutionItems) = preProject
.nuget\NuGet.Config = .nuget\NuGet.Config
.nuget\NuGet.exe = .nuget\NuGet.exe
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{95E4FDB9-247E-4BD8-896C-D28BCBA311F7}"
ProjectSection(SolutionItems) = preProject
appveyor.yml = appveyor.yml
nuspecs\Hangfire.Azure.ServiceBusQueue.nuspec = nuspecs\Hangfire.Azure.ServiceBusQueue.nuspec
psake-project.ps1 = psake-project.ps1
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HangFire.Azure.ServiceBusQueue.Tests", "tests\HangFire.Azure.ServiceBusQueue.Tests\HangFire.Azure.ServiceBusQueue.Tests.csproj", "{C9D29F07-4445-4FCB-BC38-2221B2B38231}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HangFire.Azure.ServiceBusQueue.Tests", "tests\HangFire.Azure.ServiceBusQueue.Tests\HangFire.Azure.ServiceBusQueue.Tests.csproj", "{C9D29F07-4445-4FCB-BC38-2221B2B38231}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
15 changes: 2 additions & 13 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
# - Section names should be unique on each level.

# Don't edit manually! Use `build.bat version` command instead!
version: 4.1.0-build-0{build}
version: 5.0.0-build-0{build}

os: Visual Studio 2015
os: Visual Studio 2019

#---------------------------------#
# environment configuration #
Expand All @@ -22,9 +22,6 @@ branches:
- master
- dev

cache:
- packages

#---------------------------------#
# build configuration #
#---------------------------------#
Expand All @@ -51,14 +48,6 @@ artifacts:
#---------------------------------#

deploy:
- provider: GitHub
auth_token:
secure: Kx+tJBMfq/OK7sMpvQDdigFOIIfzYkVmIHxNQetanQdIA5Mb8zm/VhAkrId4x5zW
artifact: /.*\.zip/
draft: true
on:
appveyor_repo_tag: true

- provider: NuGet
api_key:
secure: 8BQmcR1hP9MoxvrmXJKMtlRyX6LI36H9ZTU8fSEetvzMGCl1PUlXKZRUGq+GVMja
Expand Down
33 changes: 23 additions & 10 deletions nuspecs/Hangfire.Azure.ServiceBusQueue.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,36 @@
<id>Hangfire.Azure.ServiceBusQueue</id>
<version>0.0.0</version>
<title>Hangfire Azure ServiceBus Queue</title>
<authors>Sergey Odinokov, Adam Barclay</authors>
<authors>Sergey Odinokov, Adam Barclay, Giampaolo Gabba</authors>
<owners>odinserj</owners>
<projectUrl>https://github.com/odinserj/HangFire.Azure.ServiceBusQueue</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<licenseUrl>https://raw.github.com/odinserj/HangFire.Azure.ServiceBusQueue/master/license.txt</licenseUrl>
<description>Azure ServiceBus Queue support for SQL Server job storage implementation</description>
<copyright>Copyright © 2015 Sergey Odinokov, Adam Barclay</copyright>
<copyright>Copyright © 2015 Sergey Odinokov, Adam Barclay, Giampaolo Gabba</copyright>
<tags>Hangfire Azure ServiceBus SqlServer</tags>
<dependencies>
<dependency id="Hangfire.Core" version="1.7.0" />
<dependency id="Hangfire.SqlServer" version="1.7.0" />
<dependency id="WindowsAzure.ServiceBus" version="2.7.5" />
</dependencies>
<dependencies>
<group targetFramework="net461">
<dependency id="Hangfire.Core" version="1.7.0" />
<dependency id="Hangfire.SqlServer" version="1.7.0" />
<dependency id="Azure.Messaging.ServiceBus" version="7.3.0" />
</group>
<group targetFramework="netstandard2.0">
<dependency id="Hangfire.Core" version="1.7.0" />
<dependency id="Hangfire.SqlServer" version="1.7.0" />
<dependency id="Azure.Messaging.ServiceBus" version="7.3.0" />
</group>
</dependencies>
</metadata>
<files>
<file src="Net45\Hangfire.Azure.ServiceBusQueue.dll" target="lib\net45" />
<file src="Net45\Hangfire.Azure.ServiceBusQueue.xml" target="lib\net45" />
<file src="Net45\Hangfire.Azure.ServiceBusQueue.pdb" target="lib\net45" />
<file src="net461\Hangfire.Azure.ServiceBusQueue.dll" target="lib\net461" />
<file src="net461\Hangfire.Azure.ServiceBusQueue.xml" target="lib\net461" />
<file src="net461\Hangfire.Azure.ServiceBusQueue.pdb" target="lib\net461" />

<file src="netstandard2.0\Hangfire.Azure.ServiceBusQueue.dll" target="lib\netstandard2.0" />
<file src="netstandard2.0\Hangfire.Azure.ServiceBusQueue.xml" target="lib\netstandard2.0" />
<file src="netstandard2.0\Hangfire.Azure.ServiceBusQueue.pdb" target="lib\netstandard2.0" />

<file src="..\src\Hangfire.Azure.ServiceBusQueue\**\*.cs" target="src" exclude="**\obj*\**\*.cs" />
</files>
</package>
19 changes: 9 additions & 10 deletions psake-project.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ Properties {
$solution = "HangFire.Azure.ServiceBusQueue.sln"
}

Include "packages\Hangfire.Build.0.1.3\tools\psake-common.ps1"
Include "packages\Hangfire.Build.0.2.6\tools\psake-common.ps1"

Task Default -Depends Collect

Task Collect -Depends Compile -Description "Copy all artifacts to the build folder." {
Collect-Assembly "Hangfire.Azure.ServiceBusQueue" "Net45"
Task CompileCore -Depends Clean {
Exec { dotnet build -c Release }
}

Task Pack -Depends Collect -Description "Create NuGet packages and archive files." {
$version = Get-BuildVersion
Task Collect -Depends CompileCore -Description "Copy all artifacts to the build folder." {
Collect-Assembly "Hangfire.Azure.ServiceBusQueue" "net461"
Collect-Assembly "Hangfire.Azure.ServiceBusQueue" "netstandard2.0"
}

$tag = $env:APPVEYOR_REPO_TAG_NAME
if ($tag -And $tag.StartsWith("v$version-")) {
"Using tag-based version for packages."
$version = $tag.Substring(1)
}
Task Pack -Depends Collect -Description "Create NuGet packages and archive files." {
$version = Get-PackageVersion

Create-Archive "Hangfire.Azure.ServiceBusQueue-$version"
Create-Package "Hangfire.Azure.ServiceBusQueue" $version
Expand Down
72 changes: 71 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,74 @@ Hangfire v1.7+ introduced breaking changes to the SQL Server integration points
Usage
------

To use the queue it needs to be added to your existing SQL Server storage configuration, using one of the `UseServiceBusQueues` overloads:
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`:

```csharp

//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:

```csharp
var sqlStorage = new SqlServerStorage("<connection string>");
Expand Down Expand Up @@ -84,6 +151,9 @@ sqlStorage.UseServiceBusQueues(new ServiceBusQueueOptions
// 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
Expand Down
Loading