C#如何从masstransit故障消费者那里停止topshelf服务

时间:2016-09-16 08:47:23

标签: c#-4.0 rabbitmq masstransit

我在Topshelf Windows服务中运行Masstransit(使用rabbitMQ)。如果消费者有异常,我怎么能强制停止topshelf服务呢。来自FaultConsumer?

由于

1 个答案:

答案 0 :(得分:1)

挂起传递给HostControl接口的Start()方法的ServiceControl参数。如果您在任何时候需要停止请求服务,请调用Stop()方法。

public interface ServiceControl
{
    bool Start(HostControl hostControl);
    bool Stop(HostControl hostControl);
}

public interface HostControl
{
    void RequestAdditionalTime(TimeSpan timeRemaining);

    void Stop();

    void Restart();
}
相关问题