How to configure a Rebus endpoint to run as a service

纵然是瞬间 提交于 2019-12-13 00:36:09

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/27828099/how-to-configure-a-rebus-endpoint-to-run-as-a-service

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!