How can I open two connections working with massTransit To RabbitMQ servers?
Today I'm working with one connection, but I need to create more consumers in anothers Server:
services.AddMassTransit(x =>
{
//this consumer will get messages from one Exchange, and I need to create
//another consumers from anothers Exchanges.
x.AddConsumer<OptionExecutedConsumer>();
x.UsingRabbitMq((context, cfg) =>
{
cfg.Host(rabbitMQConfig.Connection.Servers[0],
rabbitMQConfig.Connection.Port,
rabbitMQConfig.Connection.VirtualHost,
h =>
{
h.Username(rabbitMQConfig.Connection.Username);
h.Password(rabbitMQConfig.Connection.Password);
h.UseCluster(c =>
{
rabbitMQConfig.Connection.Servers.ToList()
.ForEach(server => c.Node(server));
});
});
cfg.ReceiveEndpoint(rabbitMQConfig.Consumer.OptionExerciseQueue, e =>
{
e.UseRetry(r =>
r.Incremental(rabbitMQConfig.Consumer.RetryLimit,
TimeSpan.FromSeconds(rabbitMQConfig.Consumer.InitialInterval),
TimeSpan.FromSeconds(rabbitMQConfig.Consumer.IntervalIncrement)));
e.Bind(rabbitMQConfig.Consumer.OptionExerciseExchange, x =>
{
e.ConcurrentMessageLimit = 1;
e.DiscardFaultedMessages();
e.ClearMessageDeserializers();
e.UseRawJsonSerializer();
e.ConfigureConsumer<OptionExecutedConsumer>(context);
});
});
});
});
How can I create new connections using this class? Is there a best pratice to do this?