To "Pause" processing of subscriptions, should I dispose ServiceBus or Unsubscribe?

StackOverflow https://stackoverflow.com/questions/15637558

  •  29-03-2022
  •  | 
  •  

Question

I am trying to come up a good way to "pause" the processing of messages with a Mass Transit ServiceBus. Basically I have a requirement to leave my Windows Services running, but temporarily stop processing of messages.

I can only think of two ways to do this, use the subscription token, or dispose of the service bus.

Is there a preferred way of doing this, or I am heading down the wrong path?

Was it helpful?

Solution

Assuming you have some other code that needs to keep running, maybe its worth the effort to just split it into separate services?

The longer way or perhaps complimentary to the first, that offers control via messaging is to use "control" bus, i.e. another endpoint, configured with a service that can create/dispose the whole container used for the messaging infrastructure.

Another way would be to use Topshelf in its "shelves" configuration - prior to Topshelf 3 you could externally control which shelf is operating. Place the whole message processing domain into the shelf you want to control independently from the service and the rest of the service - on itsown shelf.

The downsides being:

  • it's a lot harder to debug services (interactively).
  • it will require repackaging of the service (the .exe is no longer yours, only services are).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top