You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2020/08/18 06:00:21 UTC
[camel-quarkus] 02/02: Upgarde to camel v3.4.3 (fix
MainShutdownStrategy)
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit e6a93fd88c94096fa447b18e33f90d88a07342a5
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Wed Aug 12 13:30:41 2020 +0200
Upgarde to camel v3.4.3 (fix MainShutdownStrategy)
---
.../org/apache/camel/quarkus/main/CamelMain.java | 53 ++--------------------
1 file changed, 5 insertions(+), 48 deletions(-)
diff --git a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMain.java b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMain.java
index 7e71a52..ab75ad5 100644
--- a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMain.java
+++ b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMain.java
@@ -18,8 +18,6 @@ package org.apache.camel.quarkus.main;
import java.util.Collection;
import java.util.Collections;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import io.quarkus.runtime.Quarkus;
@@ -31,6 +29,7 @@ import org.apache.camel.main.MainCommandLineSupport;
import org.apache.camel.main.MainConfigurationProperties;
import org.apache.camel.main.MainListener;
import org.apache.camel.main.MainShutdownStrategy;
+import org.apache.camel.main.SimpleMainShutdownStrategy;
import org.apache.camel.spi.CamelBeanPostProcessor;
import org.apache.camel.spi.HasCamelContext;
import org.apache.camel.support.service.ServiceHelper;
@@ -59,7 +58,10 @@ public final class CamelMain extends MainCommandLineSupport implements HasCamelC
@Override
protected void doInit() throws Exception {
- setShutdownStrategy(new ShutdownStrategy());
+ MainShutdownStrategy shutdownStrategy = new SimpleMainShutdownStrategy();
+ shutdownStrategy.addShutdownListener(() -> Quarkus.asyncExit(getExitCode()));
+
+ setShutdownStrategy(shutdownStrategy);
super.doInit();
initCamelContext();
@@ -148,49 +150,4 @@ public final class CamelMain extends MainCommandLineSupport implements HasCamelC
parseArguments(args);
runEngine();
}
-
- /**
- * Implementation of a {@link MainShutdownStrategy} based on Quarkus Command Mode.
- *
- * @see <a href="https://quarkus.io/guides/command-mode-reference">Quarkus Command Mode Applications</a>
- */
- private class ShutdownStrategy implements MainShutdownStrategy {
- private final AtomicBoolean completed;
- private final CountDownLatch latch;
-
- public ShutdownStrategy() {
- this.completed = new AtomicBoolean(false);
- this.latch = new CountDownLatch(1);
- }
-
- @Override
- public boolean isRunAllowed() {
- return !completed.get();
- }
-
- @Override
- public boolean shutdown() {
- if (completed.compareAndSet(false, true)) {
- latch.countDown();
- Quarkus.asyncExit(getExitCode());
- return true;
- }
-
- return false;
- }
-
- @Override
- public void await() throws InterruptedException {
- latch.await();
- }
-
- @Override
- public void await(long timeout, TimeUnit unit) throws InterruptedException {
- if (!latch.await(timeout, unit)) {
- LOGGER.warn(
- "Could not await stopping CamelMain within {} {}. You may want to increase camel.main.shutdown.timeout",
- timeout, unit);
- }
- }
- }
}