Reputation: 14418
I configured MassTransit on my .NET core application as follows:
public void ConfigureServices(IServiceCollection services)
{
[...]
// producer
services.AddMassTransit(x =>
{
x.AddBus(provider => Bus.Factory.CreateUsingRabbitMq(cfg =>
{
cfg.Host(new Uri(_configuration["RabbitMQ:URI"] + _configuration["RabbitMQ:VirtualHost"]), $"ENG {_configuration["SiteID"]} Producer", h =>
{
h.Username(_configuration["RabbitMQ:UserName"]);
h.Password(_configuration["RabbitMQ:Password"]);
});
cfg.Publish<NormUpdate>(x =>
{
x.Durable = true;
x.AutoDelete = false;
x.ExchangeType = "fanout"; // default, allows any valid exchange type
});
cfg.ConfigurePublish(x => x.UseExecute(x =>
{
x.Headers.Set("SiteID", _configuration["SiteID"]);
}));
}));
});
services.AddMassTransit<ISecondBus>(x =>
{
x.AddConsumer<NormConsumer>();
x.AddBus(context => Bus.Factory.CreateUsingRabbitMq(cfg =>
{
cfg.UseMessageRetry(r => r.Intervals(100, 200, 500, 800, 1000));
cfg.Host(new Uri(_configuration["RabbitMQ:URI"] + _configuration["RabbitMQ:VirtualHost"]), $"ENG {_configuration["SiteID"]} Consumer", h =>
{
h.Username(_configuration["RabbitMQ:UserName"]);
h.Password(_configuration["RabbitMQ:Password"]);
});
cfg.ReceiveEndpoint($"norm-queue-{_configuration["SiteID"]}", e =>
{
e.Durable = true;
e.AutoDelete = false;
e.Consumer<NormConsumer>(context);
e.UseConcurrencyLimit(1);
e.ExchangeType = "fanout";
e.PrefetchCount = 1;
});
}));
});
services.AddOptions<MassTransitHostOptions>().Configure(options =>
{
options.WaitUntilStarted = false;
options.StopTimeout = TimeSpan.FromSeconds(30);
});
[...]
}
public interface ISecondBus : IBus
{
}
I noticed that when connections are created, the consumer connection has 2 channels. Channel (1) with no attached consumers, channel (2) with one consumer.
I expected to have only one channel on receiver. Is this a normal behavior or am I doing something wrong?
Upvotes: 0
Views: 680
Reputation: 33457
You should have three channels:
1 + 1 + 1 = 3
Q.E.D.
Yes, I was in Math club back in primary school.
Upvotes: 1