I am running MassTransit 7.1.8 in Azure Functions v3 with Service Bus as transport. When the consumer throws an exception for the first time, two topics are created in my Service Bus namespace: masstransit~fault
(without any subscriptions) and masstransit~fault--mynamespace~myevent--
(with one subscription Fault-MassTransit
).
Azure Function Startup.cs
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.AddMassTransitForAzureFunctions(cfg =>
{
cfg.AddConsumersFromNamespaceContaining<MyConsumer>();
});
}
Azure Function
[FunctionName("MyFunction")]
public async Task Run(
[ServiceBusTrigger("my-topic", "my-subscription", Connection = "AzureWebJobsServiceBus")] Message message, ILogger log)
{
try
{
await _receiver.HandleConsumer<MyConsumer>("my-topic", "my-subscription", message, default(CancellationToken));
}
catch (System.Exception ex)
{
}
}
Consumer
public class MyConsumer : IConsumer<MyEvent>
{
public async Task Consume(ConsumeContext<MyEvent> context)
{
throw new System.Exception("Very bad things happened inside the consumer.");
}
}
I also had to manually create a subscription on masstransit~fault
to start receiving messages there.
My questions:
MyFunction
is swallowing the exception to prevent the message being sent to DLQ. Is this ok? Feels funky to swallow an exception, but on the other hand MassTransit sends the fault to the error queue so it's not lost.- The documentation talks about having an
_error
queue (prefixed appropriately) created, but I don't see any such queue nor topic, onlymasstransit~fault
andmasstransit~fault--mynamespace~myevent--
. I am guessingmasstransit~fault--mynamespace~myevent--
is Service Bus equivalent of RabbitMQ_error
? masstransit~fault--mynamespace~myevent--
has messages being sent to it, but when I look at the subscription it is empty. Subscription has a default filter that accepts everything. Do I have to do some additional configuration on the topic?- Is there a way to rename above error topics (perhaps something changed in the meantime)?