0

我使用 swarm 和 consul 拓扑构建了一个 web 服务。该服务可用于多个“通道”,因此在启动时我将每个通道的服务通告给拓扑,如下所示:

protected void startup(@Observes @Initialized(ApplicationScoped.class) Object ignore) {
    for (Channel channel : activeChannels) {
        // do some init stuff

        Topology.lookup().advertise(buildUniqueName(channel.name()));
    }
}

这很好用,我可以在我的领事网络中看到每个服务的名称、ID 和检查都正确。

但是现在当我停止服务器时,它会尝试多次自动取消注册每个服务(最多 5 次)。您可以在日志文件中看到滚动,之后服务器只是挂起并且异常开始滚动:

INFO  [org.wildfly.swarm.topology.consul.runtime.Advertiser] (MSC service thread 1-2) Deregister service service-name:<ip-and-port>
INFO  [org.wildfly.swarm.topology.consul.runtime.Advertiser] (MSC service thread 1-6) Deregister service service-name:<ip-and-port>
INFO  [org.wildfly.swarm.topology.consul.runtime.Advertiser] (MSC service thread 1-4) Deregister service service-name:<ip-and-port>
INFO  [org.wildfly.swarm.topology.consul.runtime.Advertiser] (MSC service thread 1-5) Deregister service service-name:<ip-and-port>
INFO  [org.wildfly.swarm.topology.consul.runtime.Advertiser] (MSC service thread 1-1) Deregister service service-name:<ip-and-port>


ERROR [org.wildfly.swarm.topology] (Thread-26) WFSTOPO0002: Client not registered: [Registration: service-name; <ip-and-port>; [[http]]].: com.orbitz.consul.NotRegisteredException
        at com.orbitz.consul.AgentClient.check(AgentClient.java:404)
        at com.orbitz.consul.AgentClient.checkTtl(AgentClient.java:420)
        at com.orbitz.consul.AgentClient.pass(AgentClient.java:427)
        at org.wildfly.swarm.topology.consul.runtime.Advertiser.lambda$run$2(Advertiser.java:115)
        at java.util.concurrent.ConcurrentHashMap$KeySpliterator.forEachRemaining(ConcurrentHashMap.java:3527)
        at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
        at org.wildfly.swarm.topology.consul.runtime.Advertiser.run(Advertiser.java:113)
        at java.lang.Thread.run(Thread.java:748)

这是可以理解的。然而,问题是服务器之后没有完成关闭过程。它只是挂起。

这是 wildfly-swarm 中的错误还是我必须以不同的方式使用拓扑广告?

Wildfly swarm version 2017.5.0 使用fractions topology-consul, jaxrs, cdi, jpa, logging, swagger war 打包,无主类

4

1 回答 1

0

原来是代码中的一个错误。https://issues.jboss.org/browse/SWARM-1427

将在 2017.9.0 修复

于 2017-08-28T19:24:53.693 回答