The Mongo DB Capped Collection Service Bus stores all service bus messages in a capped collection on the Mongo DB database. A capped collection is a fixed-size collection that supports tailable cursors. Tailable cursors can be used as a type of long polling mechanism, which makes use as a service bus possible.
Important: Because this service bus relies on a Mongo DB database, this module can only be used when there is a valid connection configured for the Mongo DB database module.
Installation
The Capped Collection service bus module is part of the Mongo DB provider package. Install the package with the NuGet package manager or the Package Manager Console.
PM> Install-Package Redakt.Providers.MongoDb
Service registration
Register Mongo DB Capped Collection module services in the ConfigureServices()
method of your project's Startup.cs
file by adding an AddMongoCappedCollectionServiceBus()
call to the Redakt builder instance. The order in which services are added to the Redakt builder is not important.
public void ConfigureServices(IServiceCollection services)
{
// ... framework and other services here
var builder = services.AddRedakt();
builder.AddMongoCappedCollectionServiceBus(); // Optionally pass Action<CappedCollectionServiceBusOptions> parameter.
// ... other Redakt services
}
Configuration settings
The Mongo DB Capped Collection Service Bus module is configured through the appsettings.json
file. Any configuration that is not included in the appsettings.json
file will be set to its default values. Additionally, an Action<CappedCollectionServiceBusOptions>
configuration delegate may be passed to the AddMongoCappedCollectionServiceBus()
call. Configuration set through this delegate takes priority and overrides values in the appsettings.json
file.
{
"Redakt": {
"ServiceBus": {
"MongoCappedCollection": {
"CollectionName": "ServiceBus"
}
}
}
}
Collection Name
Sets the name of the Mongo DB collection where service bus messages will be stored. The collection will automatically be created by Redakt if it does not already exist. If it does already exist, it must be a capped collection. Defaults to "ServiceBus".