【问题标题】:C# how to stop topshelf service from masstransit fault consumerC#如何从公共交通故障消费者停止topshelf服务
【发布时间】:2016-09-16 08:47:22
【问题描述】:

我在 Topshelf Windows 服务中运行 Masstransit(使用 rabbitMQ)。每当消费者出现异常时,我如何强制停止顶级服务。来自 FaultConsumer?

谢谢

【问题讨论】:

    标签: c#-4.0 rabbitmq masstransit


    【解决方案1】:

    保留传递给ServiceControl 接口的Start() 方法的HostControl 参数。如果您需要随时请求停止服务,请调用Stop() 方法。

    public interface ServiceControl
    {
        bool Start(HostControl hostControl);
        bool Stop(HostControl hostControl);
    }
    
    public interface HostControl
    {
        void RequestAdditionalTime(TimeSpan timeRemaining);
    
        void Stop();
    
        void Restart();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多