{"id":19383226,"url":"https://github.com/rebus-org/mongolianbarbecue","last_synced_at":"2025-07-16T12:08:12.925Z","repository":{"id":137920636,"uuid":"92733483","full_name":"rebus-org/MongolianBarbecue","owner":"rebus-org","description":":fire: MongoDB-based message queue","archived":false,"fork":false,"pushed_at":"2024-10-23T17:23:30.000Z","size":3624,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-22T12:59:17.980Z","etag":null,"topics":["distributed-lock","message-queue","messaging","mongo","mongodb","queue"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rebus-org.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-29T11:26:53.000Z","updated_at":"2024-10-23T17:23:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"15bd8fff-3b19-4f91-aa07-13c67ce4a0a9","html_url":"https://github.com/rebus-org/MongolianBarbecue","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebus-org%2FMongolianBarbecue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebus-org%2FMongolianBarbecue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebus-org%2FMongolianBarbecue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebus-org%2FMongolianBarbecue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rebus-org","download_url":"https://codeload.github.com/rebus-org/MongolianBarbecue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250517738,"owners_count":21443833,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["distributed-lock","message-queue","messaging","mongo","mongodb","queue"],"created_at":"2024-11-10T09:25:00.692Z","updated_at":"2025-04-23T21:31:35.538Z","avatar_url":"https://github.com/rebus-org.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mongolian Barbecue\n\nIt's just a message queue implementation that (ab)uses MongoDB to do its thing :eyes:\n\nAnother way to put it is: This library lets you pretend that MongoDB is a message queue :speak_no_evil:\n\n## Example\n\nLet's say we have a MongoDB instance running on `MONGOBONGO01`, and we want to use the `Readme` database for exchanging some messages.\n\nThe MongoDB connection string looks like this: `mongodb://MONGOBONGO01/Readme`, so we simply\n\n```csharp\nvar config = new Config(\"mongodb://MONGOBONGO01/Readme\", \"messages\");\n```\n\nto create a configuration that uses the `messages` collection for exchanging messages.\n\n:+1:\n\n\n\n## How to send messages?\n\nGrab the configuration from before and get a producer from it:\n\n```csharp\nvar producer = config.CreateProducer();\n```\n\nand then send a byte array payload to `queue-a` like this:\n\n```csharp\nvar payload = new byte[] { 0xC0, 0xFF, 0x33, 0xBA, 0xDA, 0x55 };\n\nawait producer.SendAsync(\"queue-a\", new Message(payload));\n```\n\n:clap:\n\n\n\n## How to receive messages?\n\nGo back to the configuration from before and get a consumer from it:\n\n```csharp\nvar consumer = config.CreateConsumer(\"queue-a\");\n```\n\nand then receive the next message (or null if none was to be found) like this:\n\n```csharp\nvar message = await consumer.GetNextAsync();\n\nif (message != null) \n{\n\t// we got a message - handle it here:\n\n\ttry\n\t{\n\t\tawait HandleItSomehow(message);\n\t\t\n\t\t// acknowledge it (i.e. delete the message)\n\t\tawait message.Ack();\n\t}\n\tcatch(Exception exception) \n\t{\n\t\t// try to return message immediately (don't worry if this fails - the lease will eventually expire)\n\t\tawait message.Nack();\n\n\t\tthrow;\n\t}\n}\n```\n\n:ok_hand:\n\n\n\n## How to configure things?\n\nThe constructor of the configuration object accepts a couple of optional parameters, allowing you to customize a couple of things.\n\n### Message lease timeout\n\nBy 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\n(i.e. it is deleted), but if that does not happen - e.g. if the consumer crashes \u0026 burns in a haze of `OutOfMemoryException`s and \n`StackOverflowExceptions`s - then the message will automatically become visible to other consumers again, once the lease expires.\n\nIf 60 seconds is not what you want, you can customize it like this:\n\n```csharp\nvar config = new Config(..., ..., defaultMessageLeaseSeconds: 20);\n```\n\nto lower the lease timeout to 20 seconds.\n\n### Max parallelism\n\nThe MongoDB driver does not seem to protect itself from connection pool depletion resulting from too many concurrent asynchronous\noperations, so we may limit the number of concurrent operations per `Consumer` / `Producer` object instance by passing a value\nto the configuration object like this:\n\n```csharp\nvar config = new Config(..., ..., maxParallelism: 10);\n```\n\nThe default value for \"max parallelism\" is 20.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frebus-org%2Fmongolianbarbecue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frebus-org%2Fmongolianbarbecue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frebus-org%2Fmongolianbarbecue/lists"}