Subscribe to events send on two Azure Service Bus topics

Transport: Azure Service Bus

Is it possible to subscribe on two events published on two different topics?

I managed to make it work, starting my publisher twice, with different topic name.

        var transport = new AzureServiceBusTransport(....);
        transport.Topology = TopicTopology.Single(topicName: "Topic1");
        var transport = new AzureServiceBusTransport(....);
        transport.Topology = TopicTopology.Single(topicName: "Topic2");

I know it subscribes to both of the events in both Topics, so it is no flawless.

image

Is this the same logical endpoint or a different one? From the topology above it looks like the same one (STCH.Subscriber).
You could create a subscription under stch.topics1 and forward it to stch as a workaround.topics2, but w/o understanding the context, it feels like a hack.

Yes my subscriber is the same endpoint. I have to listen to two different publisher/events, that are using different Topics.

this is a question related to using

endpointConfiguration.EnableInstallers();

If I manually setup Azure queues and subscriptions, this can be configured easily

@Stig_Christensen Usually only 1 topic exists. We would like to better understand your environment. Can you share why 2 topics exists for NServiceBus endpoints and why not a single topic can be shared?

I am using NServicebus as the subscriber in an environment with existing publishers that are not created with NServicebus . The transport is Azure Service Bus and events are published on multiple topics (One per domain). The non NServicebus-publishers will populate events with the NServiceBus.EnclosedMessageTypes header so I am able to read the events with NServicebus.

Hi @Stig_Christensen,

As mentioned by @ramonsmits, NServiceBus default behaviour is to use a single topic.
To achieve what you want you need to either as previously mentioned by @SeanFeldman, create forwarding rules in Azure to the single topic, or alternative is to configure things manually and not rely on NServiceBus installer.

Regards
John

1 Like

Yes that was also my conclusion. Though it would have been nice to be able to describe topics on an event and use EnableInstallers.

NSB single topic behavior doesn’t fit with rest of the world :slight_smile:

2 Likes

Related issue:

Great thanks !

[NServiceBus.Transport.AzureServiceBus.Topic("Finance")]
public sealed record MyEvent : IPrivate
{
}