假设我有一个有点像这样的垂直(故意简化以更容易解释我的问题)。
public class ServiceVerticle extends AbstractVerticle {
private MyService myService = new MyService();
public void start(Future<Void> startFuture) {
myService.start().addListener(done -> startFuture.complete());
}
public void stop(Future<Void> stopFuture) {
myService.stop().addListener(done -> stopFuture.complete());
}
}
现在想象这MyService
是事件驱动的,我想在服务中发生某些事件时停止垂直。
class MyService {
public void onEvent(Event event) {
//here force the service to stop and its associated verticle too
}
}
有没有对 Vert.x 有更多经验的人知道如何做到这一点?或者也许有一些建议可以告诉我什么是正确的替代方法?