Question on the Azure Service Bus Topology created by the Azure Service Bus Send/Reply Sample

More specifically, this sample: https://docs.particular.net/samples/azure-service-bus-netstandard/send-reply/

Endpoint1 and Endpoint2 are doing request/response, what I see in the Azure portal after starting the solution and running it is what I would expect to see. Two queues created, one for ep1 and one for ep2
image

After reading through these three blog posts by @danielmarbach:

I understand the reason for using message forwarding for the subscriptions for Endpoint 3 and Endpoint 4 (both these ep’s handle the same published event, Event1)
image
image
What I’m confused about is why did NSB create a subscription for ep1 and ep2? Neither of those ep’s are handling or publishing an event.

Ep1 is sending the Message1 command, Ep2 is handling Message1 and then sending Message2 back to ep1 using .Reply. Message2 is an IMessage. Ep1 is handling Message2.

Are those subscriptions actually being used by ASB to handle the routing of Message1 and Message2 between ep1 and ep2?

The reason I’m asking, is I’m currently working on a project where I’m using ASB directly, and I’m trying to wrap my head around not only the AMQP protocol, but also the concept of Topics, Subscriptions and Rules.

Never having worked directly against an AMQP-style broker before, I’m realizing how spoiled I’ve been using NSB, as working with commands, events and handlers is such a nicer, higher-level abstraction than having to get down into the weeds of ASB’s topology and API.

Thanks!

Hi Mike,

An Azure Service Bus subscription entity is preparation by NServiceBus endpoint to receive messages should it subscriber to any. The act of subscribing to an event is translated into Azure Service Bus rules entity creation (which is named after the event type it subscribes to). Each endpoint generated the subscription entity in the anticipation of NServiceBus subscriptions that will follow. There might be none. In that case, the subscription entity is a no-op with a default rule that doesn’t receive any messages.

The Topology document could help to visualize this better.

1 Like

Hi Michael

The subscription is always created but in this cause it would only contain the default rule ("$default) and no other rule because the endpoint doesn’t subscribe to any event. The subscription manager which later adds the rule is assuming the subscription is there and it can just add the rules.

It would not create the subscription if you disable the installers (in the samples the installers are always on)

Hope that helps in addition to what Sean provided

Regards
Daniel

1 Like

@SeanFeldman and @danielmarbach thanks! It was more of me wondering why those subscriptions were created, and now I understand the approach.