DbQueue.EntityFrameworkCore
1.0.6
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 2.1
This package targets .NET Standard 2.1. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package DbQueue.EntityFrameworkCore --version 1.0.6
NuGet\Install-Package DbQueue.EntityFrameworkCore -Version 1.0.6
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="DbQueue.EntityFrameworkCore" Version="1.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DbQueue.EntityFrameworkCore --version 1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DbQueue.EntityFrameworkCore, 1.0.6"
#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 DbQueue.EntityFrameworkCore as a Cake Addin #addin nuget:?package=DbQueue.EntityFrameworkCore&version=1.0.6 // Install DbQueue.EntityFrameworkCore as a Cake Tool #tool nuget:?package=DbQueue.EntityFrameworkCore&version=1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DbQueue
.NET Database concurrent Queue/Stack
Features
- SQL/NoSQL database
- Queue/Stack mode
- Concurrency
- AvailableAfter/RemoveAfter date
- Storing BLOBs in the file system
Tested on
- MS SQL Server 2019
- PostgreSQL 14
- MySQL 8.0.27
- MongoDB 5.0.3
gRPC endpoint
REST endpoint
Example 1: Queue with MsSQL via EFCore
SQL
CREATE DATABASE [DbqDatabase]
GO
CREATE TABLE [DbqDatabase].[dbo].[DbQueue]
(
[Id] BIGINT IDENTITY (1, 1) NOT NULL PRIMARY KEY,
[Queue] NVARCHAR(255) NOT NULL,
[Data] VARBINARY (MAX) NOT NULL,
[Hash] BIGINT NOT NULL,
[IsBlob] BIT NOT NULL DEFAULT 0,
[Type] NVARCHAR(255) NULL,
[AvailableAfter] BIGINT NULL,
[RemoveAfter] BIGINT NULL,
[LockId] BIGINT NULL,
INDEX [IX_DbQueue_Queue] NONCLUSTERED ([Queue]),
INDEX [IX_DbQueue_Hash] NONCLUSTERED ([Hash]),
INDEX [IX_DbQueue_LockId] NONCLUSTERED ([LockId]),
)
.NET CLI
dotnet new console --name "DbQueueExample"
cd DbQueueExample
dotnet add package DbQueue.EntityFrameworkCore
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
Program.cs:
using DbQueue;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
// add services to the container
var services = new ServiceCollection()
.AddDbqEfc((sp, options) =>
{
// add database provider
options.Database.ContextConfigurator = (db) => db.UseSqlServer("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=DbqDatabase;Integrated Security=True;Persist Security Info=False;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False");
// add blob's path construction algorithm
options.BlobStorage.PathBuilder = (filename) => Path.GetFullPath($@"_blob\{DateTime.Now:yyyy\\MM\\dd}\{filename}");
})
.BuildServiceProvider();
var queue = services.GetRequiredService<IDbQueue>();
var queueName = "examples";
// push
await queue.Push(queueName, "Some byte[], stream, string and etc...");
// pop
var received = await queue.Pop<string>(queueName).WithAutoAck();
Console.WriteLine($"pop: {received}");
Example 2: Acknowledgement usage
await using (var ack = await queue.Pop<string>(queueName))
{
// some code to save the received data, etc
// ...
// commit the acknowledgment to remove the item from the queue
await ack.Commit();
}
Example 3: Delays
await queue.Push(queueName, "example data",
availableAfter: DateTime.Now.AddDays(3),
removeAfter: DateTime.Now.AddDays(5));
Example 4: Receive many
for (var i = 0; i < 5; i++)
await queue.Push(queueName, $"item-{i}");
await foreach(var data in queue.PopMany<string>(queueName).WithAutoAck())
Console.WriteLine(data);
// Console output:
// item-0
// item-1
// item-2
// item-3
// item-4
Example 5: Stack usage
var stack = services.GetRequiredService<IDbStack>();
var stackName = "examples";
for (var i = 0; i < 5; i++)
await stack.Push(stackName, $"item-{i}");
await foreach(var data in stack.PopMany<string>(stackName).WithAutoAck())
Console.WriteLine(data);
// Console output:
// item-4
// item-3
// item-2
// item-1
// item-0
Example 6: Removing
await queue.Push(queueName, "example data 1");
await queue.Push(queueName, "example data 2", "example_type");
await queue.Push(queueName, "example data 3", "example_type");
// clear by type
await queue.Clear(queueName, "example_type");
// clear all
await queue.Clear(queueName);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- DbQueue (>= 1.0.6)
- Microsoft.EntityFrameworkCore (>= 5.0.12)
- Microsoft.EntityFrameworkCore.Relational (>= 5.0.12)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
-
net6.0
- DbQueue (>= 1.0.6)
- Microsoft.EntityFrameworkCore (>= 6.0.0)
- Microsoft.EntityFrameworkCore.Relational (>= 6.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.