DbQueue.MongoDB 1.1.4

dotnet add package DbQueue.MongoDB --version 1.1.4
                    
NuGet\Install-Package DbQueue.MongoDB -Version 1.1.4
                    
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.MongoDB" Version="1.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DbQueue.MongoDB" Version="1.1.4" />
                    
Directory.Packages.props
<PackageReference Include="DbQueue.MongoDB" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DbQueue.MongoDB --version 1.1.4
                    
#r "nuget: DbQueue.MongoDB, 1.1.4"
                    
#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.
#addin nuget:?package=DbQueue.MongoDB&version=1.1.4
                    
Install as a Cake Addin
#tool nuget:?package=DbQueue.MongoDB&version=1.1.4
                    
Install as a Cake Tool

DbQueue.MongoDB

DbQueue with MongoDB implementation of IDbqDatabase

Features

  • SQL/NoSQL database
  • Queue/Stack mode
  • Concurrency
  • AvailableAfter/RemoveAfter date
  • Storing BLOBs in the file system

Example 1: Queue with MongoDB

.NET CLI

dotnet new console --name "DbQueueExample"
cd DbQueueExample
dotnet add package DbQueue.MongoDB
dotnet add package Microsoft.Extensions.DependencyInjection

Program.cs:

using DbQueue;
using Microsoft.Extensions.DependencyInjection;


// add services to the container
var services = new ServiceCollection()
    .AddDbqMongo(options =>
    {
        // add database settings 
        options.Database.ConnectionString = "mongodb://localhost:27017";

        // 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);

More examples...

Product 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 is compatible.  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 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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.

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
1.1.4 119 11/21/2024
1.1.3 106 11/18/2024
1.1.1 105 11/17/2024
1.1.0 188 1/10/2024
1.0.8 853 11/19/2022
1.0.7 880 11/13/2021
1.0.6 357 11/13/2021
1.0.5 886 10/30/2021
1.0.4 407 10/26/2021
1.0.3 353 10/26/2021
1.0.2 468 10/24/2021
1.0.1 503 10/23/2021
1.0.0 479 10/23/2021
1.0.0-preview.2 259 10/17/2021