GithubHelp home page GithubHelp logo

hansehe / saferebus Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 223 KB

SafeRebus is a concept solution introducing how Rebus may be extended with security options to preserve safe message transactions in a distributed microservice system, and this solution implements the outbox pattern.

License: MIT License

Python 1.64% C# 97.55% Dockerfile 0.81%
rabbitmq rebus microservice docker containers message-queue message-bus dotnetcore

saferebus's Introduction

SafeRebus

Introduction

SafeRebus is a concept solution introducing how Rebus may be extended with security options to preserve safe message transactions in a distributed microservice system, and this solution implements the outbox pattern.

The solution spins up two replicas of the SafeRebus service and both of them continuously sends a set of requests which they expects to find a corresponding unique response with, during a short period of time. Unfortunately, the second replica seems to contain some severe bugs, thus it tries to break the message transactions by throwing random exceptions when handling the message requests. Additionally, multiple other spamming services tries to spam the queue with dummy requests with the intention of breaking any of the other services. The solution will stop if any of the services doesn't find the corresponding response in the database before timeout, so it is critical that none of the messages are lost.

Get Started

  1. Install Docker
  2. Install Python and pip
  3. Install python dependencies:
    • pip install -r requirements.txt
  4. See available commands:
    • python DockerBuild.py help

Build & Run

  1. Start domain development by deploying service dependencies:
    • python DockerBuild.py start-dev
  2. Build solution as container images:
    • python DockerBuild.py build
  3. Test solution in containers:
    • python DockerBuild.py test
  4. Run solution in containers:
    • python DockerBuild.py run
  5. Open solution and continue development:
  6. Publish new nuget version:
    • Bump version in CHANGELOG.md
    • Expose your api key by exposing the environment variable API_KEY
      • Linux:
        • export API_KEY=<YOUR-API_KEY>
      • Powershell:
        • $env:API_KEY = "<YOUR-API_KEY>"
    • python DockerBuild.py publish
  7. Stop development when you feel like it:
    • python DockerBuild.py stop-dev

Outbox Pattern & Duplication Filter

The outbox pattern involves storing all outgoing messages before invoking the distributed processes to send the outgoing messages. An accompaning task or service continuously resends outgoing messages which should have been sent, but failed due to a failure during the sending process, thus all outgoing messages will eventually be sent. The duplication filter ignores all duplicated message handle sessions, which may occur if a message handle process was commited, but some other occurence raised an exception before the message was acknowledged.

It should be noted the the outbox pattern is unecessary if all services are idempotent, meaning all messages may be handled multiple times with the same outcome.

Standard Adapters

SafeRebus implements a proposed standard adapter to make different amqp libraries cope with another. The standard adapter follows the robustness principle, which states the following:

  • Be conservative in what you do, be liberal in what you accept from others.

The adapter will allow a standard set of headers with body types from other libraries implementing the amqp protocol with RabbitMq, which is understood by every party. Outgoing messages will contain serialized bodies specific to the respective library (Json is default by Rebus) with headers specified by the SafeStandard proposed specification.

As an example, the safe standard is implemented with NServiceBus, which communicates with the SafeRebus implementation using the SafeStandard headers.

Additional Info

The solution spins up a RabbitMq message broker, and a PostgreSQL database. Additionally, the Portainer container management service is included to manage the container services.

  • Locate Portainer at: http://localhost:9000
  • The PostgreSQL database exposes port 5433 on the localhost for development outside of containers.
    • Access the database with the the PgAdmin4 container service on port 8080.
      • Username/password: admin/admin
    • Username/password to access the database: saferebus/saferebus
  • The RabbitMq service exposes port 5672 (AMQP) and 15672 (UI management) on the localhost, also for development outside of containers.
    • Username/password to access RabbitMq management UI: rabbituser/rabbitpassword

Buildsystem

saferebus's People

Contributors

hansehe avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

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.