{"id":15011551,"url":"https://github.com/pandatecham/be-lib-masstransit-postgres-outbox","last_synced_at":"2025-04-12T03:31:37.927Z","repository":{"id":231512142,"uuid":"781943750","full_name":"PandaTechAM/be-lib-masstransit-postgres-outbox","owner":"PandaTechAM","description":"Enhance your MassTransit applications with scalable, multi-DbContext support for PostgreSQL outbox and inbox patterns, ensuring robust message delivery and processing.","archived":false,"fork":false,"pushed_at":"2025-04-03T12:56:17.000Z","size":216,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"development","last_synced_at":"2025-04-03T13:42:06.313Z","etag":null,"topics":["distributed-systems","ef-core","inbox-pattern","library","mass-transit","messaging","microservices","modular-monolith","nuget","outbox-pattern","pandatech","postgres"],"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/PandaTechAM.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2024-04-04T10:40:44.000Z","updated_at":"2025-04-03T12:55:55.000Z","dependencies_parsed_at":"2024-04-04T11:51:21.307Z","dependency_job_id":"ec4f4748-001f-4ed6-aea7-df38e9d98d94","html_url":"https://github.com/PandaTechAM/be-lib-masstransit-postgres-outbox","commit_stats":{"total_commits":18,"total_committers":5,"mean_commits":3.6,"dds":0.5,"last_synced_commit":"6afa73f2e55f9c44694f147b86399808fa37a502"},"previous_names":["pandatecham/be-lib-pandatech-masstransit-postgres-outbox"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PandaTechAM%2Fbe-lib-masstransit-postgres-outbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PandaTechAM%2Fbe-lib-masstransit-postgres-outbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PandaTechAM%2Fbe-lib-masstransit-postgres-outbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PandaTechAM%2Fbe-lib-masstransit-postgres-outbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PandaTechAM","download_url":"https://codeload.github.com/PandaTechAM/be-lib-masstransit-postgres-outbox/tar.gz/refs/heads/development","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248512712,"owners_count":21116664,"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-systems","ef-core","inbox-pattern","library","mass-transit","messaging","microservices","modular-monolith","nuget","outbox-pattern","pandatech","postgres"],"created_at":"2024-09-24T19:41:14.419Z","updated_at":"2025-04-12T03:31:37.921Z","avatar_url":"https://github.com/PandaTechAM.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"- [1. Pandatech.MassTransit.PostgresOutbox](#1-pandatechmasstransitpostgresoutbox)\n    - [1.1. Features](#11-features)\n    - [1.2. Getting Started](#12-getting-started)\n    - [1.3. Installation](#13-installation)\n    - [1.4. Configuration](#14-configuration)\n    - [1.5. Usage](#15-usage)\n        - [1.5.1. Configuration](#151-configuration)\n        - [1.5.2. Publishing Messages (Outbox Pattern)](#152-publishing-messages-outbox-pattern)\n        - [1.5.3. Consuming Messages (Inbox Pattern)](#153-consuming-messages-inbox-pattern)\n    - [1.6. License](#16-license)\n\n# 1. Pandatech.MassTransit.PostgresOutbox\n\nWelcome to the Pandatech MassTransit PostgreSQL Outbox Extension repository. This library is designed to enhance\nMassTransit's capabilities by introducing robust support for the Outbox and Inbox patterns with a particular focus on\nPostgreSQL, alongside seamless integration with multiple DbContexts in Entity Framework Core. This extension is ideal\nfor developers seeking to ensure reliable message delivery and processing in distributed, microservice-oriented\narchitectures.\n\n## 1.1. Features\n\n- **Multiple DbContext Support**: Operate within complex systems using multiple data contexts without hassle.\n- **Outbox Pattern Implementation**: Reliably handle message sending operations, ensuring no messages are lost in\n  transit, even in the event of system failures.\n- **Inbox Pattern Support**: Process incoming messages effectively, preventing duplicate processing and ensuring message\n  consistency.\n- **PostgreSQL ForUpdate Concurrency Handling**: Utilize PostgreSQL's ForUpdate feature for enhanced concurrency\n  control, making your message handling processes more robust.\n- **Seamless Integration**: Designed to fit effortlessly into existing MassTransit and EF Core based projects.\n\n## 1.2. Getting Started\n\nTo get started with the Pandatech MassTransit PostgreSQL Outbox Extension, ensure you have the following prerequisites:\n\n- .NET Core 8 or later\n- An existing MassTransit project\n- PostgreSQL database\n\n## 1.3. Installation\n\nThe library can be installed via NuGet Package Manager. Use the following command:\n\n```bash\nInstall-Package Pandatech.MassTransit.PostgresOutbox\n``` \n\n## 1.4. Configuration\n\nBefore diving into the usage, it's essential to configure the Pandatech MassTransit PostgreSQL Outbox Extension in your\napplication. This involves setting up your DbContexts, configuring MassTransit to use the extension, and initializing\nthe Outbox and Inbox features.\n\nStay tuned for the next sections where we'll cover the usage details, showcasing how you can leverage this powerful\nextension to enhance your distributed systems.\n\n## 1.5. Usage\n\nTake into account that examples below are given for configuring both inbox and outbox patterns.\nIf you need only one of those , consider using appropriate methods available(eg. instead of AddOutboxInboxServices use\nAddInboxServices and etc).\n\n### 1.5.1. Configuration\n\n**Entity Configuration:** Ensure your `DbContext` implements the `IOutboxDbContext` and `IInboxDbContext` interfaces.\nConfigure your entities and generate migrations.\nCall `ConfigureInboxOutboxEntities` on your `ModelBuilder` to configure the necessary tables for inbox and outbox\npatterns.\n\n```csharp\nprotected override void OnModelCreating(ModelBuilder modelBuilder)\n{\n    modelBuilder.ConfigureInboxOutboxEntities();\n}\n```\n\nAnd you need to call `UseQueryLocks()` inside `AddDbContext` or `AddDbContextPool` , this needs for enabling `ForUpdate`\nfeature.\n\n```csharp\nbuilder.Services.AddDbContextPool\u003cPostgresContext\u003e(options =\u003e\n         options.UseNpgsql(connectionString)\n                .UseQueryLocks());\n```\n\n**Service Registration:** Register essential services on startup, specifying the `DbContext` type.\nYou can optionally override settings(its optional parameter).\n\n```csharp\nservices.AddOutboxInboxServices\u003cPostgresContext\u003e();\n```\n\n### 1.5.2. Publishing Messages (Outbox Pattern)\n\nTo publish a message using the outbox pattern, call the `AddToOutbox` method on your `DbContext`,\nspecifying your message. Remember to call `SaveChanges()` to persist the message to the database.\n\n```csharp\ndbContext.Orders.Add(new Order\n{\n    Amount = 555,\n    CreatedAt = DateTime.UtcNow,\n});\n\n// Add message to the outbox\ndbContext.AddToOutbox(new OrderCreatedEvent());\n\n// Save changes to the database\ndbContext.SaveChanges();\n```\n\n### 1.5.3. Consuming Messages (Inbox Pattern)\n\nTo consume messages using the inbox pattern, create a consumer that inherits from\n`InboxConsumer\u003cTMessage, TDbContext\u003e` class, specifying the message type and `DbContext` type as generic arguments.\n\n```csharp\n\npublic class YourConsumer : InboxConsumer\u003cYourMessage, PostgresContext\u003e\n{\n    private readonly PostgresContext _context;\n\n    public YourConsumer(PostgresContext dbContext, IServiceProvider sp)\n        : base(sp)\n    {\n        _context = dbContext;\n    }\n\n    public override async Task Consume(YourMessage message, IDbContextTransaction transaction)\n    {\n        // Implement your message processing logic here\n    }\n}\n```\n\n## 1.6. License\n\nPandatech.MassTransit.PostgresOutbox is licensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpandatecham%2Fbe-lib-masstransit-postgres-outbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpandatecham%2Fbe-lib-masstransit-postgres-outbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpandatecham%2Fbe-lib-masstransit-postgres-outbox/lists"}