Coder Social home page Coder Social logo

adimiko / transactionalbox Goto Github PK

View Code? Open in Web Editor NEW
38.0 2.0 0.0 2.12 MB

Outbox and Inbox Pattern in .NET (scalability & fault tolerance). Ensures eventual consistency between services. (microservices, event-driven architecture, message streaming)

Home Page: https://transactionalbox.com

License: MIT License

C# 100.00%
inbox outbox pattern 100commitow csharp 100commits bus distributed mircoservices transaction

transactionalbox's Introduction

๐Ÿšง - Under Development Licence - MIT Documentation Nugets Linkedin

โญ - The star motivates me a lot!

Transactional box is an implementation of the outbox and inbox pattern in .NET.
Ensures eventual consistency when modules need to communicate with each other over the network.

Examples of problems that occur during network communication:

  • lost messages
  • the same messages were processed again
  • unavailable services

โœจ Features

Actions

  • Add a message to send to the outbox
  • Add a message to publish to the outbox
  • Get messages from outbox and add them to transport
  • Get a message from transport and add them to the inbox
  • Get a message from inbox and process it
  • Get messages from inbox and process them

Storage

  • InMemory (Default)
  • Entity Framework (Relational)
    • Migrations
    • Distributed Lock (Based on atomic write operation, Standalone Package)
  • MongoDB

Transport

  • InMemory (Default)
  • Apache Kafka
  • RabbitMQ
  • Iggy

Scalability & Fault Tolerance

  • Support for multiple outbox worker instances
    • Multiple instances of the same service
    • Multiple processes in the same service
  • Support for multiple inbox instances
    • Multiple instances of the same service
    • Multiple processes in the same service
  • Standalone outbox worker
  • Standalone inbox
  • Error handling in background services
  • Task throttling in background services (Long Running Jobs and Max Degree of Parallelism for Jobs)
  • Dead messages
  • Hook from service to outbox worker (when service add new message to outbox)
    • InMemory
    • SignalR
  • When the inbox adds messages to the storage, it should notify the service that the messages should be processed

Observability

  • Support for OpenTelemetry
  • Outbox size
  • Inbox size
  • Message failure rate
  • Message delivery latency
  • Number of duplicated messages
  • Message duplication rate

Maintenecne

  • Remove processed messages from the outbox
  • Remove processed messages from the inbox
  • Remove expired idempotency keys
  • Archive processed messages from the outbox
  • Archive processed messages from the inbox
  • Correlation ID

Other

  • Modular package architecture
  • Support for TimeProvider
  • Unordered messages
  • Internal high-performance logging (Source Generators)
  • Execution context in Inbox
  • High-performance invoking of inbox message handlers from assemblies (Compiled Lambda Expressions)
  • Grouping of messages
    • Group by topic outbox messages to a single transport message from batch (better compression)
    • Adjusting optimal transport message size
  • Messages serialization and deserialization
    • System.Text.Json (default)
  • Messages compression and decompression
    • No compression (default)
    • Brotli
    • GZip
  • Message streaming
  • Package configuration using appsetings.json
  • Own transport message serialier and deseralizer (with StringBuilder)
  • Idempotent messages
  • Keyed in memory lock (based on SemaphoreSlim and ConcurrentDictionary)
  • Transport discriminator (one outbox many transport, tagged message)

๐ŸŽฌ Run Sample

Note

Docker is required.

Clone this repo and open TransactionalBox.sln via Visual Studio 2022. Set the TransactionalBox.Sample.WebApi as startup and then run. You should see the following view.

Have fun ๐Ÿ˜ƒ!

๐Ÿฐ Architecture

The transactional box consists of four basic components. The following diagrams show the basic flow (omits details).

Outbox

Outbox is responsible for adding messages to the storage.

Outbox Worker

Outbox worker is responsible for getting the messages from storage and adding them to the transport.

Inbox Worker

Inbox worker is responsible for getting messages from transport and adding them to the storage.

Inbox

Inbox is responsible for processing messages from the storage.

๐Ÿ… Competition '100commitow'

The project is part of the competition 100 commitow.

Topics

  • Distributed lock (prevent race condition)
  • Hook processing
  • Concurrency control
  • Scaling and parallel processing (distributed processing)
  • Synchronization primitives
  • Idempotency
  • Retry Pattern

transactionalbox's People

Contributors

adimiko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

transactionalbox's Issues

using for DistributedLock

DistributedLock should be used with using, because when will be exception Dispose method will be executed and lock will be released.

HostName Service

Wrap Dns.GetHostName() to app service

Place where can be used

  • TransactionalBox.OutboxWorker.Kafka

Outbox worker: processing in packages

OutobxWorker should get the package of messages and add them to the transport.
It should then mark as processed the messages that have been added to the transport.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.