【发布时间】:2020-10-09 02:34:27
【问题描述】:
我们正在以下列方式关闭 cometd 客户端。有没有办法确保所有未决事件都已发布?有时我们会看到一些在触发关闭之前发送的事件丢失的问题。
public void shutdown() {
try {
if (bayeuxClient != null) {
bayeuxClient.getChannel(getChannelInfo()).unsubscribe();
bayeuxClient.disconnect(10000L);
bayeuxClient.waitFor(10000L, BayeuxClient.State.DISCONNECTED);
}
if (client != null) {
client.stop();
}
} catch (Exception e) {
log.warn(e.getMessage());
} finally {
client = null;
bayeuxClient = null;
}
}
【问题讨论】: