[英]Using TopShelf to create a simple MQ windows service
I am using Topshelf for creating a simple MQ reading service.我正在使用 Topshelf 创建一个简单的 MQ 阅读服务。 Since the documentation available is sparse - I have run into some probably simple questions that I hope get answered here:
由于可用的文档很少 - 我遇到了一些可能很简单的问题,希望在这里得到解答:
1) Generally - it would be very nice to get the actual servicebase instance of my service instance, since there is a bunch of methods that I would like to access. 1) 通常 - 获得我的服务实例的实际 servicebase 实例会非常好,因为有一堆我想访问的方法。 How can I do that?
我怎样才能做到这一点?
2) When OnStop is called, I would like to flush the MQ and quickly process the remaining messages. 2)当调用 OnStop 时,我想刷新 MQ 并快速处理剩余的消息。 However, accessing the MQ in the OnClose raises an MQ access exception - is this by design, or?
但是,在 OnClose 中访问 MQ 会引发 MQ 访问异常——这是设计使然,还是?
3) I have specified the OnPause and OnContinue overloads in the configurator. 3) 我在配置器中指定了 OnPause 和 OnContinue 重载。 However - the service is not pause/continue enabled, since the AllowPauseAndContinue flag is not set.
但是 - 服务未启用暂停/继续,因为未设置 AllowPauseAndContinue 标志。 What is the best way to do that?
最好的方法是什么?
var retVal = HostFactory.New( x =>
{
x.Service<ASForwardMessageService>( s =>
{
s.SetServiceName( s_ServiceName );
s.ConstructUsing( name => CreateService() );
s.WhenStarted( tc => tc.OnStart() );
s.WhenStopped( tc => tc.OnStop() );
s.WhenPaused( tc => tc.OnPause() );
s.WhenContinued( tc => tc.OnContinue() );
} );
x.RunAsLocalSystem();
x.DependsOnMsmq();
x.StartAutomatically();
x.SetDescription( s_Description );
x.SetDisplayName( s_DisplayName );
x.SetServiceName( s_ServiceName );
} );
By the way - is there any documentation available for the Topshelf project - would be very nice to have around.顺便说一句 - 是否有任何可用于 Topshelf 项目的文档 - 很高兴有。
Thanks for a great library!感谢一个很棒的图书馆!
https://github.com/Topshelf/Topshelf/wiki for documentation, there's also http://topshelf-project.com/ but we don't really have much in terms of docs up there. https://github.com/Topshelf/Topshelf/wiki用于文档,还有http://topshelf-project.com/但我们在文档方面并没有太多。 This might be a better discussion for our mailing list as well.
这对于我们的邮件列表也可能是一个更好的讨论。
We don't expose that, though I guess it's possible we could via the new pre- and post- install events (http://legomaster.net/2011/02/announcing-topshelf-2-2/).我们不会公开这一点,但我想我们可以通过新的安装前和安装后事件 (http://legomaster.net/2011/02/announcing-topshelf-2-2/)。 The general idea is that anything you would need to set would be exposed via our configuration API though.
一般的想法是,您需要设置的任何内容都将通过我们的配置 API 公开。 What attention items do you want access to you feel that you don't have now?
您希望获得哪些您认为您现在没有的关注项目?
What exception are you seeing?你看到了什么异常? There isn't anything I'm aware of in the design of Topshelf which should be causing this issue.
我所知道的 Topshelf 设计中没有任何东西会导致这个问题。
CanPauseAndContinue
isn't set; CanPauseAndContinue
未设置; drop an issue in our issue tracker on github and I think that's something that can be resolved.在 github 上的问题跟踪器中删除问题,我认为这是可以解决的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.