简体   繁体   English

使用 TopShelf 创建一个简单的 MQ windows 服务

[英]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.这对于我们的邮件列表也可能是一个更好的讨论。

  1. 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?您希望获得哪些您认为您现在没有的关注项目?

  2. 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 设计中没有任何东西会导致这个问题。

  3. 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.

相关问题 Windows服务已启动,然后使用Topshelf停止 - Windows Service started and then stopped using Topshelf 使用 TopShelf 创建 Windows 服务时出现“错误 1053 服务没有响应”错误 - "Error 1053 The Service did not respond" error when using TopShelf to create a Windows Service 作为 windows 服务运行的多线程控制台应用程序(使用 Topshelf) - Multithreaded console application that runs as windows service (using Topshelf) Windows 服务 memory 泄漏使用 TopShelf 和 Automapper c# - Windows service memory leak using TopShelf and Automapper c# 没有加载任何符号-Windows Service和Topshelf - No symbols have been loaded - windows service and topshelf 如何使用Topshelf将asp.net Core 2.1 MVC应用程序部署为Windows服务 - How to deploy asp.net core 2.1 MVC application as windows service using topshelf 使用 TopShelf 的 Windows 服务:底层提供程序在打开时失败。 用户登录失败 - Windows service using TopShelf: The underlying provider failed on Open. User logon failure 如何在每天的特定时间使用 c# 中的 topshelf 安排 windows 服务 - How to Schedule a windows service using topshelf in c# at specific time in a each day 使用Topshelf设置服务启动参数 - Set Service Start Parameter using Topshelf 使用Topshelf重新启动窗口服务后,重新创建文件夹 - Re-create folder after re-start of window service using Topshelf
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM