I have a simple code as bellow, I can see that the memory keeps increase forever. I’m not sure what I am missing here.
Thank you.
using MassTransit;
using TestNamespace;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddMassTransit(x =>
{
x.AddConsumer<TestHandler>();
x.UsingInMemory((context, cfg) =>
{
cfg.ConfigureEndpoints(context);
});
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.MapGet("/weatherforecast", async (IBus bus) =>
{
for (var i = 0; i < 1_000_000; i++)
{
await bus.Publish(new Test
{
});
}
})
.WithName("GetWeatherForecast")
.WithOpenApi();
app.Run();
namespace TestNamespace
{
public class Test
{
}
public class TestHandler: IConsumer<Test>
{
public async Task Consume(ConsumeContext<Test> context)
{
}
}
}