Skip to content

RabbitMQ

Bernardo Teixeira edited this page Oct 22, 2021 · 3 revisions

I'm using the RabbitMQ Client version 6.2.2. I'm also using Polly for retries and Serilog for all the logging. And Newtonsoft.Json for serialization and deserialization.

Register

To register the ApolloBus, you need to addRabbitMq(...) StartupFile

  public void ConfigureServices(IServiceCollection services)
  {
     services.AddRabbitMq(Configuration);
      ...
  }

To add the configuration, you need to write in your appsetting the following code.

  "RabbitMQ": {
    "Config": {
      "HostName": "localhost",
      "UserName": "guest",
      "Password": "guest",
      "VirtualHost": "/",
      "Port": 5672
    },
    "ComplementaryConfig": {
      "Retry" :5,
      "QueueName": "QueueTest01",
      "BrokenName": "BrokenTest01"
    }
  }

The object Config is the same object from the RabbitMq client give us -> ConnectionFactory.

The object ComplementaryConfig, this object is just for configuration the retries and the name of the queue and broken.