ScientificBit.MongoDbMQ
1.0.0
dotnet add package ScientificBit.MongoDbMQ --version 1.0.0
NuGet\Install-Package ScientificBit.MongoDbMQ -Version 1.0.0
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="ScientificBit.MongoDbMQ" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ScientificBit.MongoDbMQ --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ScientificBit.MongoDbMQ, 1.0.0"
#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 ScientificBit.MongoDbMQ as a Cake Addin #addin nuget:?package=ScientificBit.MongoDbMQ&version=1.0.0 // Install ScientificBit.MongoDbMQ as a Cake Tool #tool nuget:?package=ScientificBit.MongoDbMQ&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MongoDbMQ
A Simple .NET Core based Message Queue which uses MongoDb.
Usage
Define a message class
public class QueueTestMessage
{
public string Message { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}
Define Consumers
public class QueueTestMessageConsumer : MongoDbMessageConsumer<QueueTestMessage>
{
protected override Task ConsumeAsync(QueueTestMessage message)
{
Console.WriteLine($"Received message: {message.Message}");
return Task.CompletedTask;
}
}
Configure MongoDbMQ for publishing and consuming messages
// Assuming IServiceCollection is already created
services.ConfigureMongoDbMessageQueue(opts =>
{
// Replace with your real connection string
opts.ConnectionString = "mongodb://localhost:27017";
// Replace with your real messaged database name
opts.QueueDbName = "test-messages";
// Register consumers - This is required, only if the application consumes messages
opts.RegisterConsumer<QueueTestMessage, QueueTestMessageConsumer>();
});
Publishing a Message
// Inject in service
using ScientificBit.MongoDbMQ.Abstraction;
public class MessagePublisher
{
private readonly IMongoDbMessageBus _messageBus;
public class MessagePublisher(IMongoDbMessageBus messageBus)
{
_messageBus = messageBus;
}
public async Task<string> PublishMessage(string msg)
{
var messageId = await _messageBus.PublishAsync(msg);
return messageId;
}
}
Issues
TBD
Contributing
TBD
Documentation
TBD
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- Microsoft.Extensions.Hosting (>= 7.0.1)
- MongoDB.Driver (>= 2.21.0)
- Newtonsoft.Json (>= 13.0.3)
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.0.0 | 140 | 9/12/2023 |