{"id":22104172,"url":"https://github.com/brianpursley/npgmq","last_synced_at":"2025-07-25T01:32:00.679Z","repository":{"id":234510081,"uuid":"720516143","full_name":"brianpursley/Npgmq","owner":"brianpursley","description":"A .NET client for Postgres Message Queue (PGMQ).","archived":false,"fork":false,"pushed_at":"2024-08-08T13:43:50.000Z","size":60,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-17T12:17:00.834Z","etag":null,"topics":["csharp","dotnet","pgmq","postgres","postgresql","queues"],"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/brianpursley.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}},"created_at":"2023-11-18T18:14:44.000Z","updated_at":"2024-10-30T00:42:23.000Z","dependencies_parsed_at":"2024-06-28T19:47:20.548Z","dependency_job_id":"b66a406a-0e45-4623-9f33-a777c0936ae0","html_url":"https://github.com/brianpursley/Npgmq","commit_stats":null,"previous_names":["brianpursley/npgmq"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brianpursley%2FNpgmq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brianpursley%2FNpgmq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brianpursley%2FNpgmq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brianpursley%2FNpgmq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brianpursley","download_url":"https://codeload.github.com/brianpursley/Npgmq/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227500548,"owners_count":17781307,"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":["csharp","dotnet","pgmq","postgres","postgresql","queues"],"created_at":"2024-12-01T06:28:49.776Z","updated_at":"2025-07-25T01:32:00.666Z","avatar_url":"https://github.com/brianpursley.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Npgmq\n\nA .NET client for [Postgres Message Queue](https://github.com/tembo-io/pgmq) (PGMQ).\n\n[![Build](https://github.com/brianpursley/Npgmq/actions/workflows/build.yml/badge.svg)](https://github.com/brianpursley/Npgmq/actions/workflows/build.yml)\n[![Nuget](https://img.shields.io/nuget/v/Npgmq)](https://www.nuget.org/packages/Npgmq/)\n![License](https://img.shields.io/github/license/brianpursley/Npgmq)\n\n## Compatibility\n\n* pgmq \u003e= 0.31.0\n\n## Installation\nTo install the package via [Nuget](https://www.nuget.org/packages/Npgmq/), run the following command:\n\n```shell\ndotnet add package Npgmq\n```\n\n## Usage\n\nHere is an example that uses Npgmq to create a queue and then send/read/archive a message:\n\n```csharp\nusing Npgmq;\n\nvar npgmq = new NpgmqClient(\"\u003cYOUR CONNECTION STRING HERE\u003e\");\n\nawait npgmq.InitAsync();\n\nawait npgmq.CreateQueueAsync(\"my_queue\");\n\nvar msgId = await npgmq.SendAsync(\"my_queue\", new MyMessageType\n{\n    Foo = \"Test\",\n    Bar = 123\n});\nConsole.WriteLine($\"Sent message with id {msgId}\");\n\nvar msg = await npgmq.ReadAsync\u003cMyMessageType\u003e(\"my_queue\");\nif (msg != null)\n{\n    Console.WriteLine($\"Read message with id {msg.MsgId}: Foo = {msg.Message?.Foo}, Bar = {msg.Message?.Bar}\");\n    await npgmq.ArchiveAsync(\"my_queue\", msg.MsgId);\n}\n```\n\nThis example assumes you have defined a class called `MyMessageType` with the structure something like:\n\n```csharp\npublic class MyMessageType\n{\n    public string Foo { get; set; } = null!;\n    public int Bar { get; set; }\n}\n```\n\nYou can send and read messages as JSON strings, like this:\n\n```csharp   \nvar msgId = await npgmq.SendAsync(\"my_queue\", \"{\\\"foo\\\":\\\"Test\\\",\\\"bar\\\":123}\");\nConsole.WriteLine($\"Sent message with id {msgId}\");\n\nvar msg = await npgmq.ReadAsync\u003cstring\u003e(\"my_queue\");\nif (msg != null)\n{\n    Console.WriteLine($\"Read message with id {msg.MsgId}: {msg.Message}\");\n    await npgmq.ArchiveAsync(\"my_queue\", msg.MsgId);\n}\n```\n\nYou can pass your own `NpgsqlConnection` to the `NpgmqClient` constructor, like this:\n\n```csharp\nusing var myConnection = new NpgsqlConnection(\"\u003cYOUR CONNECTION STRING HERE\u003e\");\nvar npgmq = new NpgmqClient(myConnection);\n```\n\n## Database Connection\n\nNpgmq uses [Npgsql](https://www.npgsql.org/) internally to connect to the database.\n\n### Using a Connection String\n\nIf you pass an [Npgsql connection string](https://www.npgsql.org/doc/connection-string-parameters.html) to the `NpgmqClient` constructor, it will use this connection string to create an [`NpgsqlConnection`](https://www.npgsql.org/doc/api/Npgsql.NpgsqlConnection.html) object internally, and the connection lifetime will be managed by NpgmqClient.\n\n### Using a Connection Object\n\nIf you pass an [`NpgsqlConnection`](https://www.npgsql.org/doc/api/Npgsql.NpgsqlConnection.html) object to the `NpgmqClient` constructor, it will use this connection instead of creating its own.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrianpursley%2Fnpgmq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrianpursley%2Fnpgmq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrianpursley%2Fnpgmq/lists"}