zarusz / SlimMessageBus

Lightweight message bus interface for .NET (pub/sub and request-response) with transport plugins for popular message brokers.
Apache License 2.0
465 stars 77 forks source link

[Host | Feature request] Toggle consumers by health check tag(s) #251

Open EtherZa opened 4 months ago

EtherZa commented 4 months ago

TLDR; associate consumers with health checks to enable/disable them as the status of dependent services change

I haven't seen this implemented in a competing library, and it may be beyond the "slim" scope, but all the same it may be a feature that garners interest. It would certainly be useful in my environment.

Consumers often require different downstream services to fulfil their execution. One may need a specific database instance, another network storage, while a third may require a third party API (or a combination of services) to be available. When one of these dependencies become unavailable, the consumer needs to be resilient and handle the failure gracefully or fail successively before the message ends up in the dead letter queue.

If consumers were to be associated with the health checks of their dependent services, then they could be individually started/stopped on a health status change. Disabling only the impacted consumer(s) would ease the impact while allowing uneffected consumers to continue processing messages unimpeded.

A potential solution is to have a proxy sitting between MessageBusBase and the Consumers to intercept Start/Stop events while monitoring health checks (tags) to start/stop the consumer as appropriate.

zarusz commented 4 months ago

@EtherZa Sounds like a good use case. If you willing to contribute I am happy to review a PR. Perhaps it's a circuit breaker even.

EtherZa commented 4 months ago

@zarusz I'll take a look at it, but it may take a little longer to implement.