Publish Event: No exception when Azure Service Bus Topic does not exist

When I publish an event and the underlying Azure Service Bus topic does not exists, I do not get any feedback. I’d have expected an exception and I wonder if it’s possible to get any feedback.

Context

  • we’re upgrading to NServiceBus.Transport.AzureServiceBus v5 and start using the new Topic per Event Topology (before that we used bundle-1)
  • the topics are deployed to our ASB Namespace through Terraform scripts (not automatically through NSB)

Steps to reproduce

  1. publish an event (no outbox, transaction, etc. required)
  2. if the topic exists, this works perfectly fine
  3. if the topic does not exist, the code runs fine but obviously no event is published – I’d expect an exception or other feedback
var options = new PublishOptions();
options.RequireImmediateDispatch(); // optional
await session.Publish(new SomethingHasHappened(), options);

Analysis/Impact

  • in NServiceBus.Transport.AzureServiceBus.MessageDispatcher.DispatchForDestination the ServiceBusException is caught (when MessagingEntityNotFound) and debug-logged/swallowed
  • I understand that it might be less error-prone if we let NSB automatically create the topics (but I would still not be 100% confident that this works in all scenarios)

This behavior is by design:

The subscriber will create the topic AND the subscription to its endpoint queue.

If you need this as part of an integration then you can use operational scripting if you have a non NServiceBus subscriber:

I see, thanks!

Quite frankly though, this looks a bit implicit and hard to troubleshoot if when anything goes wrong. So I’d appreciate the chance to opt into different behaviour in future versions. :slight_smile:

We would appreciate if you could create a feature request for this at:

This way you will also receive any progress made with this.

Here you go: Return/throw Error when Topic does not exist (Azure Service Bus with new topology) · Issue #1255 · Particular/NServiceBus.Transport.AzureServiceBus · GitHub

1 Like