arcus-azure / arcus.messaging

Messaging with Microsoft Azure in a breeze.
https://messaging.arcus-azure.net
MIT License
20 stars 11 forks source link

Message pump tries to delete subscription on stop #432

Closed fgheysels closed 4 months ago

fgheysels commented 7 months ago

It looks like the default-behavior of an Arcus MessagePump which is configured to consume a topic, is to delete the subscription it is using when the MessagePump stops:

image Luckily my service principal is not allowed to delete the topic-subscription.

In my opinion, this is something that we should not do by default. Nor should it be configured to create the subscription by default.

In the projects we're working on, we typically deploy all (Azure) resources via 'infrastructure as code'. That means that we also setup the topic-subscriptions via IaC.
A subscription also has filters; this is something that you carefully define and you define that upfront.

Next to that, suppose the message-pump runs in a Kubernetes cluster or Container App environment. It is very possible that the component suddenly restarts for some reason and then restarts; in such cases, you really don't want that the subscription is being deleted when the message-pump stops, and is re-created automatically when the pump restarts (the filters that have been defined will not be automatically correctly recreated).

stijnmoreels commented 6 months ago

Think this was a functionality that was added before there was even anything like Kubernetes. Think it was a bit like GetOrCreate... functionality, but yes, it is already very old and maybe lost a bit of context.

fgheysels commented 6 months ago

Next to that, this also means that, when your application stops, you will not be able to handle the messages that were produced when your application was down. The subscription that it uses is not there, hence you won't have messages

fgheysels commented 5 months ago

to be honest, I think this is something that must be tackled (and released) ASAP. To avoid breaking current behaviour, creation / deletion of subscriptions should be made configurable. The default setting could -for now- define that the subscription should be created / deleted in such a way that the current existing behaviour remains. (Although I'm not a fan of it :) ).

stijnmoreels commented 5 months ago

Will be focusing on the .NET 8 support and the needed releases for that. Only after that, I will be able to focus on something else. Feel free to have a look already, though, so we can place it in the .NET 8 major release. 👍

fgheysels commented 5 months ago

I can see that it's already possible to change this behaviour via the AzureServiceBusMessagePumpOptions. Since we're deploying a new major release next, I think I would even consider to change the default behaviour so that the subscription is not auto-created nor auto-deleted.