{"id":23399567,"url":"https://github.com/mustaddon/dbqueue","last_synced_at":"2025-10-07T23:45:32.793Z","repository":{"id":115863815,"uuid":"418103608","full_name":"mustaddon/DbQueue","owner":"mustaddon","description":".NET Database concurrent Queue/Stack","archived":false,"fork":false,"pushed_at":"2024-11-21T08:27:22.000Z","size":142,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-05T11:05:33.416Z","etag":null,"topics":["asp-net-core","aspnetcore","concurrency","csharp","db-queue","dbqueue","dotnet","grpc","mongodb","mssql","mysql","nosql","queue","rest-api","sql","stack"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mustaddon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2021-10-17T11:10:03.000Z","updated_at":"2024-11-22T06:23:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"d74dfd5c-c55b-429e-ab9b-6972e5a3b980","html_url":"https://github.com/mustaddon/DbQueue","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mustaddon/DbQueue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustaddon%2FDbQueue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustaddon%2FDbQueue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustaddon%2FDbQueue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustaddon%2FDbQueue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mustaddon","download_url":"https://codeload.github.com/mustaddon/DbQueue/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustaddon%2FDbQueue/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278866939,"owners_count":26059670,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["asp-net-core","aspnetcore","concurrency","csharp","db-queue","dbqueue","dotnet","grpc","mongodb","mssql","mysql","nosql","queue","rest-api","sql","stack"],"created_at":"2024-12-22T10:14:42.756Z","updated_at":"2025-10-07T23:45:32.734Z","avatar_url":"https://github.com/mustaddon.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DbQueue [![NuGet version](https://badge.fury.io/nu/DbQueue.svg?)](http://badge.fury.io/nu/DbQueue)\nDatabase concurrent Queue/Stack\n\n\n## Features\n* SQL/NoSQL database\n* Queue/Stack mode\n* Concurrency\n* AvailableAfter/RemoveAfter date\n* Storing BLOBs in the file system\n\n\n## Tested on\n* MS SQL Server 2019\n* PostgreSQL 14\n* MySQL 8.0.27\n* MongoDB 5.0.3\n\n\n## gRPC endpoint\n* [Service](https://github.com/mustaddon/DbQueue/tree/main/DbQueue.Grpc/)\n* [Client](https://github.com/mustaddon/DbQueue/tree/main/DbQueue.Grpc.Client/)\n\n\n## REST endpoint\n* [Service](https://github.com/mustaddon/DbQueue/tree/main/DbQueue.Rest/)\n* [Client](https://github.com/mustaddon/DbQueue/tree/main/DbQueue.Rest.Client/)\n\n\n## Example 1: Queue with MsSQL via EFCore\nSQL\n```sql\nCREATE DATABASE [DbqDatabase] \nGO\nCREATE TABLE [DbqDatabase].[dbo].[DbQueue]\n(\n    [Id] BIGINT IDENTITY (1, 1) NOT NULL PRIMARY KEY,\n    [Queue] NVARCHAR(255) NOT NULL,\n    [Data] VARBINARY (MAX) NOT NULL,\n    [Hash] BIGINT NOT NULL,\n    [IsBlob] BIT NOT NULL DEFAULT 0,\n    [Type] NVARCHAR(255) NULL,\n    [AvailableAfter] BIGINT NULL,\n    [RemoveAfter] BIGINT NULL,\n    [LockId] BIGINT NULL,\n    INDEX [IX_DbQueue_Queue] NONCLUSTERED ([Queue]),\n    INDEX [IX_DbQueue_Hash] NONCLUSTERED ([Hash]),\n    INDEX [IX_DbQueue_LockId] NONCLUSTERED ([LockId]),\n)\n```\n\n.NET CLI\n```cli\ndotnet new console --name \"DbQueueExample\"\ncd DbQueueExample\ndotnet add package DbQueue.EntityFrameworkCore\ndotnet add package Microsoft.EntityFrameworkCore.SqlServer\n```\n\nProgram.cs:\n```C#\nusing DbQueue;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.Extensions.DependencyInjection;\n\n\n// add services to the container\nvar services = new ServiceCollection()\n    .AddDbqEfc(options =\u003e\n    {\n        // add database provider \n        options.Database.ContextConfigurator = (db) =\u003e db.UseSqlServer(\"Data Source=(localdb)\\\\MSSQLLocalDB;Initial Catalog=DbqDatabase;Integrated Security=True;Persist Security Info=False;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False\");\n\n        // add blob's path construction algorithm \n        options.BlobStorage.PathBuilder = (filename) =\u003e Path.GetFullPath($@\"_blob\\{DateTime.Now:yyyy\\\\MM\\\\dd}\\{filename}\");\n    })\n    .BuildServiceProvider();\n\n\nvar queue = services.GetRequiredService\u003cIDbQueue\u003e();\nvar queueName = \"examples\";\n\n// push\nawait queue.Push(queueName, \"Some byte[], stream, string and etc...\");\n\n// pop\nvar received = await queue.Pop\u003cstring\u003e(queueName).WithAutoAck();\nConsole.WriteLine($\"pop: {received}\");\n```\n\n\n## Example 2: Acknowledgement usage\n```C#\nawait using (var ack = await queue.Pop\u003cstring\u003e(queueName))\n{\n    // some code to save the received data, etc\n    // ...\n    // commit the acknowledgment to remove the item from the queue\n    await ack.Commit();\n}\n```\n\n\n## Example 3: Delays\n```C#\nawait queue.Push(queueName, \"example data\", \n    availableAfter: DateTime.Now.AddDays(3),\n    removeAfter: DateTime.Now.AddDays(5));\n```\n\n\n## Example 4: Receive many\n```C#\nfor (var i = 0; i \u003c 5; i++)\n    await queue.Push(queueName, $\"item-{i}\");\n\nawait foreach(var data in queue.PopMany\u003cstring\u003e(queueName).WithAutoAck())\n    Console.WriteLine(data);\n\n\n// Console output:\n// item-0\n// item-1\n// item-2\n// item-3\n// item-4\n```\n\n\n## Example 5: Stack usage\n```C#\nvar stack = services.GetRequiredService\u003cIDbStack\u003e();\nvar stackName = \"examples\";\n\nfor (var i = 0; i \u003c 5; i++)\n    await stack.Push(stackName, $\"item-{i}\");\n\nawait foreach(var data in stack.PopMany\u003cstring\u003e(stackName).WithAutoAck())\n    Console.WriteLine(data);\n\n\n// Console output:\n// item-4\n// item-3\n// item-2\n// item-1\n// item-0\n```\n\n\n## Example 6: Removing\n```C#\nawait queue.Push(queueName, \"example data 1\");\nawait queue.Push(queueName, \"example data 2\", \"example_type\");\nawait queue.Push(queueName, \"example data 3\", \"example_type\");\n\n// clear by type\nawait queue.Clear(queueName, \"example_type\");\n\n// clear all\nawait queue.Clear(queueName);\n```\n\n[More examples...](https://github.com/mustaddon/DbQueue/tree/main/Examples/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmustaddon%2Fdbqueue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmustaddon%2Fdbqueue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmustaddon%2Fdbqueue/lists"}