MongolianBarbecue 3.0.2
dotnet add package MongolianBarbecue --version 3.0.2
NuGet\Install-Package MongolianBarbecue -Version 3.0.2
<PackageReference Include="MongolianBarbecue" Version="3.0.2" />
paket add MongolianBarbecue --version 3.0.2
#r "nuget: MongolianBarbecue, 3.0.2"
// Install MongolianBarbecue as a Cake Addin #addin nuget:?package=MongolianBarbecue&version=3.0.2 // Install MongolianBarbecue as a Cake Tool #tool nuget:?package=MongolianBarbecue&version=3.0.2
Mongolian Barbecue
It's just a message queue implementation that (ab)uses MongoDB to do its thing 👀
Another way to put it is: This library lets you pretend that MongoDB is a message queue 🙊
Example
Let's say we have a MongoDB instance running on MONGOBONGO01
, and we want to use the Readme
database for exchanging some messages.
The MongoDB connection string looks like this: mongodb://MONGOBONGO01/Readme
, so we simply
var config = new Config("mongodb://MONGOBONGO01/Readme", "messages");
to create a configuration that uses the messages
collection for exchanging messages.
👍
How to send messages?
Grab the configuration from before and get a producer from it:
var producer = config.CreateProducer();
and then send a byte array payload to queue-a
like this:
var payload = new byte[] { 0xC0, 0xFF, 0x33, 0xBA, 0xDA, 0x55 };
await producer.SendAsync("queue-a", new Message(payload));
👏
How to receive messages?
Go back to the configuration from before and get a consumer from it:
var consumer = config.CreateConsumer("queue-a");
and then receive the next message (or null if none was to be found) like this:
var message = await consumer.GetNextAsync();
if (message != null)
{
// we got a message - handle it here:
try
{
await HandleItSomehow(message);
// acknowledge it (i.e. delete the message)
await message.Ack();
}
catch(Exception exception)
{
// try to return message immediately (don't worry if this fails - the lease will eventually expire)
await message.Nack();
throw;
}
}
👌
How to configure things?
The constructor of the configuration object accepts a couple of optional parameters, allowing you to customize a couple of things.
Message lease timeout
By default, a message is made invisible for 60 seconds when it is received. If it is ACKed within that time, it is removed from the queue
(i.e. it is deleted), but if that does not happen - e.g. if the consumer crashes & burns in a haze of OutOfMemoryException
s and
StackOverflowExceptions
s - then the message will automatically become visible to other consumers again, once the lease expires.
If 60 seconds is not what you want, you can customize it like this:
var config = new Config(..., ..., defaultMessageLeaseSeconds: 20);
to lower the lease timeout to 20 seconds.
Max parallelism
The MongoDB driver does not seem to protect itself from connection pool depletion resulting from too many concurrent asynchronous
operations, so we may limit the number of concurrent operations per Consumer
/ Producer
object instance by passing a value
to the configuration object like this:
var config = new Config(..., ..., maxParallelism: 10);
The default value for "max parallelism" is 20.
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. |
.NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
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. |
-
.NETFramework 4.7.2
- mongodb.driver (>= 3.0.0)
- nito.asyncex (>= 5.1.2)
-
.NETStandard 2.1
- mongodb.driver (>= 3.0.0)
- nito.asyncex (>= 5.1.2)
-
net6.0
- mongodb.driver (>= 3.0.0)
- nito.asyncex (>= 5.1.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MongolianBarbecue:
Package | Downloads |
---|---|
Mongrow
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.0.2 | 232 | 10/23/2024 |
3.0.1 | 76 | 10/23/2024 |
3.0.0 | 81 | 10/23/2024 |
2.1.0 | 8,222 | 8/14/2024 |
2.0.0 | 585 | 3/29/2023 |
1.0.0 | 140,982 | 11/28/2018 |
1.0.0-b12 | 969 | 5/31/2018 |
1.0.0-b11 | 968 | 5/31/2018 |
1.0.0-b10 | 957 | 5/31/2018 |
1.0.0-b09 | 967 | 6/1/2017 |
1.0.0-b08 | 905 | 5/30/2017 |
1.0.0-b07 | 896 | 5/30/2017 |
1.0.0-b06 | 902 | 5/30/2017 |
1.0.0-b05 | 867 | 5/30/2017 |
1.0.0-b04 | 929 | 5/29/2017 |
1.0.0-b03 | 952 | 5/29/2017 |
1.0.0-b02 | 871 | 5/29/2017 |
1.0.0-b01 | 881 | 5/29/2017 |