[英]Is there any scenario in which a Vert.x MessageConsumer can fail to unregister from the event bus?
public void unregisterConsumer(MessageConsumer<Object> mc) {
mc.unregister(result -> {
if(result.succeeded())
return;
else
//uh oh
});
}
如果AsyncResult
失敗,再次調用unregisterConsumer
是不明智的,可能使用vertx.setTimer(5000, id -> unregisterConsumer(mc));
?
如果 Vert.x 沒有集群,那么失敗的可能性可以忽略不計(它只會在出現錯誤的情況下發生)。
如果 Vert.x 是集群的,如果底層集群管理器未能刪除訂閱(例如,如果網絡通信丟失),則可能會發生這種情況。
至於重試,如果您的應用程序動態注冊消費者可能是一個好主意。 否則,您可以忽略失敗並讓進程終止。 集群管理器最終會清理訂閱。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.