Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ademcatamak/messagestorage
Message and Job Storage with Outbox Design Pattern
https://github.com/ademcatamak/messagestorage
fire-and-forget masstransit nuget nuget-package outbox outbox-pattern postgres postgresql sql-server sql-server-database transactional-outbox transactional-outbox-pattern
Last synced: about 1 month ago
JSON representation
Message and Job Storage with Outbox Design Pattern
- Host: GitHub
- URL: https://github.com/ademcatamak/messagestorage
- Owner: AdemCatamak
- License: mit
- Archived: true
- Created: 2020-01-05T20:47:19.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-11T22:39:28.000Z (almost 2 years ago)
- Last Synced: 2024-09-25T18:43:57.615Z (about 1 month ago)
- Topics: fire-and-forget, masstransit, nuget, nuget-package, outbox, outbox-pattern, postgres, postgresql, sql-server, sql-server-database, transactional-outbox, transactional-outbox-pattern
- Language: C#
- Homepage:
- Size: 420 KB
- Stars: 20
- Watchers: 4
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: ReadMe.md
- License: License
Awesome Lists containing this project
README
# Message Storage
MessageStorage is a library prepared to be used in projects that want to apply the **Outbox** design pattern.
| Platform | Status |
| ------- | ----- |
| `Travis` | ![Travis](https://travis-ci.com/AdemCatamak/MessageStorage.svg?branch=master) |
| `GitHub` | ![.github/workflows/github.yml](https://github.com/AdemCatamak/MessageStorage/workflows/.github/workflows/github.yml/badge.svg?branch=master) || NuGet Package Name | Version |
| ------- | ----- |
| MessageStorage.SqlServer | ![Nuget](https://img.shields.io/nuget/v/MessageStorage.SqlServer.svg) |
| MessageStorage.Postgres | ![Nuget](https://img.shields.io/nuget/v/MessageStorage.Postgres.svg) |
| MessageStorage.Integration.MassTransit | ![Nuget](https://img.shields.io/nuget/v/MessageStorage.Integration.MassTransit.svg) |## Structure Overview
## Getting Started
You can download the _MessageStorage.SqlServer_ or _MessageStorage.Postgres_ package
according to the storage environment you will use.`UseSqlServer` / `UsePostgres` method lets you introduce SqlServer or Postgres is used for system's data storage.
`RegisterHandler` / `RegisterHandlers` method lets you introduce MessageHandlers that is used. When the message is recorded, the tasks that will be
executed in the background will be introduced through these classes.### Sample Startup
```
services.AddMessageStorage(configurator =>
{
configurator.UseSqlServer("SqlServerConnectionString");
configurator.RegisterHandlers(messageHandlerAssemblies);
})
```After these steps, you can use the object that is an implementation of `IMessageStorageClient` interface.
### Sample Service
Example of registering SomeEntity and saving SomeEntityCreatedEvent message in the same transaction.
```
using (IDbConnection connection = _connectionFactory.CreateConnection())
{
using IDbTransaction dbTransaction = connection.BeginTransaction(IsolationLevel.ReadCommitted);
using IMessageStorageTransaction transaction = _messageStorageClient.UseTransaction(dbTransaction);
await connection.ExecuteAsync( sqlCommandText, sqlCommandParameters, dbTransaction);SomeEntityCreated someEntityCreated = new (someEntity.Id, someEntity.SomeProperty, someEntity.CreatedOn);
await _messageStorageClient.AddMessageAsync(someEntityCreated);transaction.CommitAsync(cancellationToken);
}
```After `transaction.CommitAsync`, created job will be dispatched and executed