Is there an equivalent to "IWantToRunWhenEndpointStartsAndStops" when selfhosting?


(Matt Ritchie) #1

I’m migrating from NSB.Host to selfhosted consoleapps, which i’m going to install with sc.exe.

I’ve just removed the NSB.Host package as i don’t want the exe to be generated in my build, now IWantToRunWhenEndpointStartsAndStops interface has gone.

Is there an interface to hook into this pipeline, or should i just inline the code into my selfhost startup?

PS. discourse didn’t let me post "IWantToRunWhenEndpointStartsAndStops " in title.


(Tim Bussmann) #2

there is no direct equivalent to IWantToRunWhenEndpointStartsAndStops in the core. In general, the recommended approach is to just call whatever you would place in IWantToRunWhenEndpointStartsAndStops after starting the endpoint.

There is an alternative approach if you want to reuse your “startup” code in multiple endpoints: Features can declare a FeatureStartupTask which are called when starting and stopping the endpoint. There are more details about FeatureStartupTasks in the feature doco page: https://docs.particular.net/nservicebus/pipeline/features?version=core_7#feature-startup-tasks

Discourse has a few default topic title name policies which are not ideal in our case, I’ll see whether I can loosen the restrictions a bit. Thanks for the feedback!
edit: I updated the title