GithubHelp home page GithubHelp logo

rabbitmq.routing's Introduction

MassTransit and RabbitMQ routing to tenant-specific consumers on .NET

There are 3 projects.

  1. Core - shared classes.
  2. Sender - A simple project which sends the message.
  3. Consumer - A consumer project that accepts the message for a tenant defined in configuration.

Try it

1. Setup your RabbitMQ with default settings

Default is set in the Sender and Consumer projects, but you can change them to your needs:

configurator.Host("localhost",
    5672,
    "/", h =>
    {
       h.Username("guest");
       h.Password("guest");
    });

2. Configure and Run a consumer

Open the appsettings.json in the consumer and populate the tenantID you want to use for the consumer. For example:

{
...
    "TenantId": "f49fc7a9-155a-4d84-86bd-8276431524e1",
...
}

Now you can run the consumer, which will generate the RabbitMQ infrastructure and start listening for the messages.

3. Run Sender and send a message

Run Sender service and go to the /swagger and execute the sender endpoint. The below action will be triggered. Use the tenantId you specified in the step 2 above.

[HttpGet]
public async Task Send(string tenantId)
{
   await _sender.Publish(new MyMessage()
    {
        ID = "23423",
        Name = "My message",
        TenantId = tenantId
    });

   Ok();
}

Now you can try to run the second consumer with a different tenantID and try to send messages to both :).

rabbitmq.routing's People

Contributors

mihaj avatar

Watchers

 avatar  avatar

Forkers

rawdenhoff

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.