I use masstransit 8 + amazon sqs/sns, the app is running in Windows Docker container.
I've noticed that adding custom filter to consumers leads to the issue - name of topic and subscription lose their scope prefix. Though the queue itself has always the correct name (with prefix).
Steps to re-produce the issue:
Filter:
public sealed class CustomConsumeFilter<T> : IFilter<ConsumeContext<T>> where T: class
{
public async Task Send(ConsumeContext<T> context, IPipe<ConsumeContext<T>> next)
{
await next.Send(context);
}
public void Probe(ProbeContext context)
{
}
}
Consumer:
public class TestModelEventsConsumer : IConsumer<TestModel>
{
public Task Consume(ConsumeContext<TestModel> context)
{
return Task.CompletedTask;
}
}
Masstransit initialization:
var builder = Host.CreateApplicationBuilder(args);
var configuration = builder.Configuration;
builder.Services
.Configure<AmazonSqsTransportOptions>(configuration.GetSection("MassTransit:Transports:AmazonSqs"))
.AddMassTransit(bus =>
{
bus.AddConsumer<TestModelEventsConsumer>();
bus.UsingAmazonSqs((context, sqs) =>
{
sqs.UseFilter(new CustomConsumeFilter<TestModel>()); // the issue is in this line
var entityNameFormatter = new MessageNameFormatterEntityNameFormatter(new AmazonSqsMessageNameFormatter());
var scope = "test-prefix-";
sqs.MessageTopology.SetEntityNameFormatter(new PrefixEntityNameFormatter(entityNameFormatter, scope));
sqs.ConfigureEndpoints(context, new KebabCaseEndpointNameFormatter(scope));
});
});
builder.Build().Run();
If I run the code with line "sqs.UseFilter" the following objects will be created:
If I remove the line "sqs.UseFilter" the proper names will be created for objects:
I didn't think that simple filter code affect tha name of objects. Setting the scope prefix "test-prefix-" I expect all objects (queue, topic, subscription) to have the prefix no matter if filter is using or not. Could you please advise if this a bug or not and how to resolve it ?
Thanks, Evgeny.
Order matters, configure the topology settings before you add any filters or configure any endpoints.