How to configure a Rebus endpoint to run as a serv

2019-08-05 04:34发布

I am trying to use Topshelf to create a Rebus endpoint that will run as a service. How should this be set up and are there any examples?

标签: rebus
1条回答
戒情不戒烟
2楼-- · 2019-08-05 05:06

You can take a look at the Rebus samples repository, where the integration service sample in particular shows what you're after.

As you can see in Program.cs it uses Topshelf to basically just hold on to a Windsor container, which it disposes when the application shuts down.

The Castle Windsor installer syntax causes the installers to be automatically picked up, where the RebusInstaller shows how you'd typically let Rebus inject itself into your container, and the HandlerInstaller shows how you can add handlers to the container.

It should be fairly easy to adapt the sample to use another container - just remember to dispose it when the application shuts down, thus giving Rebus a chance to finish messages currently being handled and stop its worker threads.

查看更多
登录 后发表回答