NServiceBus.Transport.AzureServiceBus icon indicating copy to clipboard operation
NServiceBus.Transport.AzureServiceBus copied to clipboard

Send-only endpoint does not create the publish Topic if it does not exist

Open SeanFeldman opened this issue 6 years ago • 5 comments

Who's affected

Anyone using pub/sub in one of the following scenarios:

  1. The Subscriber has never executed and the publisher run firs w/o installers enabled.
  2. The subscribers has never executed and the publisher run as send-only endpoint.

Symptoms

Publisher throws an exception when trying to publish an event.

Details

Topic for published events is created along with queues. If an endpoint is either send-only or installers have been disabled, queue creation will not take place. Subsequently, the topic won't be created either. In case subscribers have not executed, it will mean there will be no topic to publish events to and the publisher will throw an exception.

This is only a problem that can occur on a clean namespace depending on the order of starting the endpoints the first time (rare edge case)

Original issue

Raised on the public forum here.

Workarounds

  1. Create topic manually.
  2. Run any non send-only endpoint that has installers enabled first.
  3. Using the operational scripting tool to create the topic

SeanFeldman avatar Jan 23 '19 06:01 SeanFeldman

@SeanFeldman do you know what should be the correct behavior?

SzymonPobiega avatar Jan 23 '19 14:01 SzymonPobiega

The legacy ASB had this behaviour, but arguably, it was the way it was. For the new transport, endpoints should be able to just publish. Wherever there's a topic or not. This will also be more aligned with broker-based transports such as RabbitMQ that handles this situation.

SeanFeldman avatar Jan 23 '19 18:01 SeanFeldman

Fix for this issue will require a breaking change. Therefore we will introduce it in the next major release rather than right away as there are viable workarounds. As well as topic creation needs to take place once and once on;y per environment.

When version 2.0.0 is worked on, we'll include the fix for this issue as well.

SeanFeldman avatar Jan 27 '19 19:01 SeanFeldman

I am going to relabel this as an improvement instead of a bug. The current functionality is by design (send-only endpoints do not create infrastructure). It would be a new "feature" of the transport to be able to ensure a topic is created in this scenario. This new feature would align with customer expectations and create alignment with other brokered transports as Sean mentioned.

boblangley avatar Jan 19 '21 21:01 boblangley

This could be implemented in the next major using the new transport seam that clearly separates subscription at startup vs subscription at runtime. For subscription at startup, the behavior could be changed to the following, if there is no manage rights we assume everything is already properly set up and just continue starting. If the endpoint is started with manage rights we will create the topic.

With such a general assumption around least-privilege, we could follow the same pattern for a send-only endpoint.

danielmarbach avatar Feb 18 '21 17:02 danielmarbach

Was this done in V8?

SeanFeldman avatar Oct 06 '23 03:10 SeanFeldman

I created a send-only endpoint with installers enabled using v8, which generates the topic if it does not exist. It doesn't however generate the topic if installers are not enabled.

awright18 avatar Oct 10 '23 20:10 awright18

That should suffice.

SeanFeldman avatar Oct 10 '23 20:10 SeanFeldman