Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't let potential failures in message consumers cause dev mode shutdown to be blocked permanently #16253

Merged
merged 1 commit into from
Apr 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void registerMessageConsumers(Map<String, ConsumeEvent> messageConsumerConfigura
if (!messageConsumerConfigurations.isEmpty()) {
EventBus eventBus = vertx.eventBus();
CountDownLatch latch = new CountDownLatch(messageConsumerConfigurations.size());
final List<Throwable> registrationFailures = new ArrayList();
for (Entry<String, ConsumeEvent> entry : messageConsumerConfigurations.entrySet()) {
EventConsumerInvoker invoker = createInvoker(entry.getKey());
String address = entry.getValue().value();
Expand Down Expand Up @@ -117,8 +118,9 @@ public void handle(Promise<Object> event) {

@Override
public void handle(AsyncResult<Void> ar) {
if (ar.succeeded()) {
latch.countDown();
latch.countDown();
if (ar.failed()) {
registrationFailures.add(ar.cause());
}
}
});
Expand All @@ -130,6 +132,10 @@ public void handle(AsyncResult<Void> ar) {
Thread.currentThread().interrupt();
throw new IllegalStateException("Unable to register all message consumer methods", e);
}
if (!registrationFailures.isEmpty()) {
// just log/raise the first failure
throw new RuntimeException("Registration of one or more message consumers failed", registrationFailures.get(0));
}
}
}

Expand All @@ -147,8 +153,9 @@ void unregisterMessageConsumers() {
CountDownLatch latch = new CountDownLatch(messageConsumers.size());
for (MessageConsumer<?> messageConsumer : messageConsumers) {
messageConsumer.unregister(ar -> {
if (ar.succeeded()) {
latch.countDown();
latch.countDown();
if (ar.failed()) {
LOGGER.warn("Message consumer unregistration failed", ar.cause());
}
});
}
Expand Down