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 2019/10/07 07:49:16 UTC
[camel-quarkus] branch master updated: Add support for quarkus
provided event loop #131
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
The following commit(s) were added to refs/heads/master by this push:
new c8bffa2 Add support for quarkus provided event loop #131
c8bffa2 is described below
commit c8bffa2c59a9d5ca4fef74a40c90351b3ddccfc1
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Mon Oct 7 00:10:28 2019 +0200
Add support for quarkus provided event loop #131
---
.../ROOT/pages/_partials/component-extensions.adoc | 1 +
.../quarkus/core/deployment/BuildProcessor.java | 27 ++++++-
.../CamelReactiveExecutorBuildItem.java} | 29 +++++---
.../quarkus/core/deployment/CamelSupport.java | 9 ++-
.../camel/quarkus/core/CamelMainRecorder.java | 9 +++
.../camel/quarkus/core/FastCamelContext.java | 4 +-
.../apache/camel/quarkus/core/RuntimeRegistry.java | 36 ++++++++++
extensions/pom.xml | 1 +
extensions/reactive-executor/deployment/pom.xml | 77 ++++++++++++++++++++
.../executor/deployment/BuildProcessor.java} | 26 +++----
.../reactive/executor/deployment/Feature.java} | 20 +++---
extensions/reactive-executor/pom.xml | 39 ++++++++++
extensions/reactive-executor/runtime/pom.xml | 84 ++++++++++++++++++++++
.../executor/ReactiveExecutorRecorder.java} | 22 +++---
integration-tests/core-main/test/pom.xml | 4 ++
.../apache/camel/quarkus/core/CamelServlet.java | 22 +++++-
.../org/apache/camel/quarkus/core/CamelTest.java | 14 ++++
poms/bom-deployment/pom.xml | 5 ++
poms/bom/pom.xml | 10 +++
19 files changed, 385 insertions(+), 54 deletions(-)
diff --git a/docs/modules/ROOT/pages/_partials/component-extensions.adoc b/docs/modules/ROOT/pages/_partials/component-extensions.adoc
index 0481b4d..f8a301c 100644
--- a/docs/modules/ROOT/pages/_partials/component-extensions.adoc
+++ b/docs/modules/ROOT/pages/_partials/component-extensions.adoc
@@ -14,6 +14,7 @@
* `camel-quarkus-netty-http`
* `camel-quarkus-paho`
* `camel-quarkus-platform-http`
+* `camel-quarkus-reactive-executor`
* `camel-quarkus-rest`
* `camel-quarkus-salesforce`
* `camel-quarkus-servlet`
diff --git a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
index 142ae07..63b8f71 100644
--- a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
+++ b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
@@ -66,7 +66,22 @@ class BuildProcessor {
RuntimeValue<Registry> registry = recorder.createRegistry();
- CamelSupport.services(applicationArchives).forEach(si -> {
+ CamelSupport.services(applicationArchives)
+ .filter(si -> {
+ //
+ // by default all the service found in META-INF/service/org/apache/camel are
+ // bound to the registry but some of the services are then replaced or set
+ // to the camel context directly by extension so it does not make sense to
+ // instantiate them in this phase.
+ //
+ boolean blacklisted = si.path.endsWith("reactive-executor") || si.path.endsWith("platform-http");
+ if (blacklisted) {
+ LOGGER.debug("Ignore service: {}", si);
+ }
+
+ return !blacklisted;
+ })
+ .forEach(si -> {
LOGGER.debug("Binding bean with name: {}, type {}", si.name, si.type);
recorder.bind(
@@ -174,13 +189,21 @@ class BuildProcessor {
CamelMainRecorder recorder,
CamelMainBuildItem main,
// TODO: keep this as placeholder to ensure the registry is fully configured
- // befire startuing the camel context
+ // before starting the camel context
CamelRuntimeRegistryBuildItem registry,
+ // TODO: replace with @Overridable
+ List<CamelReactiveExecutorBuildItem> reactiveExecutors,
ShutdownContextBuildItem shutdown,
// TODO: keep this list as placeholder to ensure the ArC container is fully
// started before starting main
List<ServiceStartBuildItem> startList) {
+ if (reactiveExecutors.size() > 1) {
+ throw new IllegalArgumentException("Detected multiple reactive executors");
+ } else if (reactiveExecutors.size() == 1) {
+ recorder.setReactiveExecutor(main.getInstance(), reactiveExecutors.get(0).getInstance());
+ }
+
recorder.start(shutdown, main.getInstance());
}
}
diff --git a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeRegistry.java b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelReactiveExecutorBuildItem.java
similarity index 51%
copy from extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeRegistry.java
copy to extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelReactiveExecutorBuildItem.java
index 9324e8e..af6255c 100644
--- a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeRegistry.java
+++ b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelReactiveExecutorBuildItem.java
@@ -14,20 +14,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.core;
+package org.apache.camel.quarkus.core.deployment;
+
+import io.quarkus.builder.item.MultiBuildItem;
import io.quarkus.runtime.RuntimeValue;
-import org.apache.camel.support.DefaultRegistry;
+import org.apache.camel.quarkus.core.CamelMain;
+import org.apache.camel.spi.ReactiveExecutor;
+
+/**
+ * Holds the {@link CamelMain} {@link RuntimeValue}.
+ *
+ * TODO: should extend SimpleBuildItem when moving to quarkus snapshots or 0.24
+ * as we can then use the @Overridable annotation which allow to provide
+ * alternative implementation of a build item.
+ */
+public final class CamelReactiveExecutorBuildItem extends MultiBuildItem {
+ private final RuntimeValue<ReactiveExecutor> instance;
-public class RuntimeRegistry extends DefaultRegistry {
- public RuntimeRegistry() {
- super(new RuntimeBeanRepository());
+ public CamelReactiveExecutorBuildItem(RuntimeValue<ReactiveExecutor> instance) {
+ this.instance = instance;
}
- @Override
- public Object unwrap(Object value) {
- return (value instanceof RuntimeValue)
- ? ((RuntimeValue)value).getValue()
- : value;
+ public RuntimeValue<ReactiveExecutor> getInstance() {
+ return instance;
}
}
diff --git a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelSupport.java b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelSupport.java
index 418c442..29b254f 100644
--- a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelSupport.java
+++ b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelSupport.java
@@ -102,7 +102,7 @@ public final class CamelSupport {
for (Map.Entry<Object, Object> entry : props.entrySet()) {
String k = entry.getKey().toString();
if (k.equals("class")) {
- answer.add(new ServiceInfo(name, entry.getValue().toString()));
+ answer.add(new ServiceInfo(p, name, entry.getValue().toString()));
}
}
} catch (Exception e) {
@@ -117,10 +117,12 @@ public final class CamelSupport {
* services from resources belonging to META-INF/services/org/apache/camel.
*/
public static class ServiceInfo {
+ public final Path path;
public final String name;
public final String type;
- public ServiceInfo(String name, String type) {
+ public ServiceInfo(Path path, String name, String type) {
+ this.path = path;
this.name = name;
this.type = type;
}
@@ -128,7 +130,8 @@ public final class CamelSupport {
@Override
public String toString() {
return "ServiceInfo{"
- + "name='" + name + '\''
+ + "path='" + path.toString() + '\''
+ + ", name=" + name
+ ", type=" + type
+ '}';
}
diff --git a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMainRecorder.java b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMainRecorder.java
index c2d206c..3ca6435 100644
--- a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMainRecorder.java
+++ b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMainRecorder.java
@@ -24,13 +24,19 @@ import io.quarkus.runtime.ShutdownContext;
import io.quarkus.runtime.annotations.Recorder;
import org.apache.camel.CamelContext;
import org.apache.camel.RoutesBuilder;
+import org.apache.camel.impl.engine.DefaultReactiveExecutor;
import org.apache.camel.main.MainListener;
import org.apache.camel.model.Model;
+import org.apache.camel.spi.ReactiveExecutor;
import org.apache.camel.support.ResourceHelper;
import org.apache.camel.util.ObjectHelper;
@Recorder
public class CamelMainRecorder {
+ public RuntimeValue<ReactiveExecutor> createReactiveExecutor() {
+ return new RuntimeValue<>(new DefaultReactiveExecutor());
+ }
+
public RuntimeValue<CamelMain> createCamelMain(
RuntimeValue<CamelContext> runtime,
BeanContainer container) {
@@ -87,6 +93,9 @@ public class CamelMainRecorder {
main.getValue().addMainListener(listener);
}
+ public void setReactiveExecutor(RuntimeValue<CamelMain> main, RuntimeValue<ReactiveExecutor> executor) {
+ main.getValue().getCamelContext().setReactiveExecutor(executor.getValue());
+ }
public void start(ShutdownContext shutdown, RuntimeValue<CamelMain> main) {
shutdown.addShutdownTask(new Runnable() {
@Override
diff --git a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastCamelContext.java b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastCamelContext.java
index 163bd3b..a94b129 100644
--- a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastCamelContext.java
+++ b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastCamelContext.java
@@ -50,6 +50,7 @@ import org.apache.camel.impl.engine.DefaultMessageHistoryFactory;
import org.apache.camel.impl.engine.DefaultNodeIdFactory;
import org.apache.camel.impl.engine.DefaultPackageScanClassResolver;
import org.apache.camel.impl.engine.DefaultProcessorFactory;
+import org.apache.camel.impl.engine.DefaultReactiveExecutor;
import org.apache.camel.impl.engine.DefaultRouteController;
import org.apache.camel.impl.engine.DefaultStreamCachingStrategy;
import org.apache.camel.impl.engine.DefaultTracer;
@@ -58,7 +59,6 @@ import org.apache.camel.impl.engine.DefaultUnitOfWorkFactory;
import org.apache.camel.impl.engine.DefaultValidatorRegistry;
import org.apache.camel.impl.engine.EndpointKey;
import org.apache.camel.impl.engine.HeadersMapFactoryResolver;
-import org.apache.camel.impl.engine.ReactiveExecutorResolver;
import org.apache.camel.impl.engine.RestRegistryFactoryResolver;
import org.apache.camel.impl.engine.ServicePool;
import org.apache.camel.impl.health.DefaultHealthCheckRegistry;
@@ -380,7 +380,7 @@ public class FastCamelContext extends AbstractCamelContext {
@Override
protected ReactiveExecutor createReactiveExecutor() {
- return new ReactiveExecutorResolver().resolve(this);
+ return new DefaultReactiveExecutor();
}
@Override
diff --git a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeRegistry.java b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeRegistry.java
index 9324e8e..35214d5 100644
--- a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeRegistry.java
+++ b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeRegistry.java
@@ -16,7 +16,11 @@
*/
package org.apache.camel.quarkus.core;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
import io.quarkus.runtime.RuntimeValue;
+import org.apache.camel.spi.BeanRepository;
import org.apache.camel.support.DefaultRegistry;
public class RuntimeRegistry extends DefaultRegistry {
@@ -30,4 +34,36 @@ public class RuntimeRegistry extends DefaultRegistry {
? ((RuntimeValue)value).getValue()
: value;
}
+
+ //
+ // DefaultRegistry does not merge results from the repositories
+ // and fallback registry so in case beans are bound to the local
+ // registry only but any of the configured repositories returns
+ // a non null answer, then the local values are not taken into
+ // account for the final answer.
+ //
+ // TODO: fix upstream and remove this method
+ //
+ @Override
+ public <T> Set<T> findByType(Class<T> type) {
+ final Set<T> answer = new LinkedHashSet<>();
+
+ if (repositories != null) {
+ for (BeanRepository r : repositories) {
+ Set<T> instances = r.findByType(type);
+ if (instances != null && !instances.isEmpty()) {
+ answer.addAll(instances);
+ }
+ }
+ }
+
+ Set<T> instances = fallbackRegistry.findByType(type);
+ if (instances != null && !instances.isEmpty()) {
+ for (T instance: instances) {
+ answer.add((T)unwrap(instance));
+ }
+ }
+
+ return answer;
+ }
}
diff --git a/extensions/pom.xml b/extensions/pom.xml
index 1096421..a3c920d 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -40,6 +40,7 @@
<module>core</module>
<module>core-cloud</module>
<module>http-common</module>
+ <module>reactive-executor</module>
<!-- components -->
<module>netty-http</module>
diff --git a/extensions/reactive-executor/deployment/pom.xml b/extensions/reactive-executor/deployment/pom.xml
new file mode 100644
index 0000000..7d1fdda
--- /dev/null
+++ b/extensions/reactive-executor/deployment/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-reactive-executor-parent</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-reactive-executor-deployment</artifactId>
+ <name>Camel Quarkus :: Core :: Reactive Executor :: Deployment</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-reactive-executor</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-vertx-deployment</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeRegistry.java b/extensions/reactive-executor/deployment/src/main/java/org/apache/camel/quarkus/reactive/executor/deployment/BuildProcessor.java
similarity index 50%
copy from extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeRegistry.java
copy to extensions/reactive-executor/deployment/src/main/java/org/apache/camel/quarkus/reactive/executor/deployment/BuildProcessor.java
index 9324e8e..649beb6 100644
--- a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeRegistry.java
+++ b/extensions/reactive-executor/deployment/src/main/java/org/apache/camel/quarkus/reactive/executor/deployment/BuildProcessor.java
@@ -14,20 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.core;
+package org.apache.camel.quarkus.reactive.executor.deployment;
-import io.quarkus.runtime.RuntimeValue;
-import org.apache.camel.support.DefaultRegistry;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.ExecutionTime;
+import io.quarkus.deployment.annotations.Record;
+import io.quarkus.vertx.deployment.VertxBuildItem;
+import org.apache.camel.quarkus.core.Flags;
+import org.apache.camel.quarkus.core.deployment.CamelReactiveExecutorBuildItem;
+import org.apache.camel.quarkus.reactive.executor.ReactiveExecutorRecorder;
-public class RuntimeRegistry extends DefaultRegistry {
- public RuntimeRegistry() {
- super(new RuntimeBeanRepository());
- }
-
- @Override
- public Object unwrap(Object value) {
- return (value instanceof RuntimeValue)
- ? ((RuntimeValue)value).getValue()
- : value;
+public class BuildProcessor {
+ @Record(ExecutionTime.RUNTIME_INIT)
+ @BuildStep(onlyIfNot = Flags.MainDisabled.class)
+ CamelReactiveExecutorBuildItem reactiveExecutor(ReactiveExecutorRecorder recorder, VertxBuildItem vertx) {
+ return new CamelReactiveExecutorBuildItem(recorder.createReactiveExecutor(vertx.getVertx()));
}
}
diff --git a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeRegistry.java b/extensions/reactive-executor/deployment/src/main/java/org/apache/camel/quarkus/reactive/executor/deployment/Feature.java
similarity index 65%
copy from extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeRegistry.java
copy to extensions/reactive-executor/deployment/src/main/java/org/apache/camel/quarkus/reactive/executor/deployment/Feature.java
index 9324e8e..ae24845 100644
--- a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeRegistry.java
+++ b/extensions/reactive-executor/deployment/src/main/java/org/apache/camel/quarkus/reactive/executor/deployment/Feature.java
@@ -14,20 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.core;
+package org.apache.camel.quarkus.reactive.executor.deployment;
-import io.quarkus.runtime.RuntimeValue;
-import org.apache.camel.support.DefaultRegistry;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
-public class RuntimeRegistry extends DefaultRegistry {
- public RuntimeRegistry() {
- super(new RuntimeBeanRepository());
- }
+public class Feature {
+ private static final String FEATURE = "camel-reactive-executor";
- @Override
- public Object unwrap(Object value) {
- return (value instanceof RuntimeValue)
- ? ((RuntimeValue)value).getValue()
- : value;
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
}
}
diff --git a/extensions/reactive-executor/pom.xml b/extensions/reactive-executor/pom.xml
new file mode 100644
index 0000000..8236bbe
--- /dev/null
+++ b/extensions/reactive-executor/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-build-parent</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <relativePath>../../poms/build-parent/pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-quarkus-reactive-executor-parent</artifactId>
+ <name>Camel Quarkus :: Core :: Reactive Executor</name>
+ <packaging>pom</packaging>
+ <modules>
+ <module>deployment</module>
+ <module>runtime</module>
+ </modules>
+
+</project>
diff --git a/extensions/reactive-executor/runtime/pom.xml b/extensions/reactive-executor/runtime/pom.xml
new file mode 100644
index 0000000..9751130
--- /dev/null
+++ b/extensions/reactive-executor/runtime/pom.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-reactive-executor-parent</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-reactive-executor</artifactId>
+ <name>Camel Quarkus :: Core :: Reactive Executor :: Runtime</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core</artifactId>
+ </dependency>
+
+ <!-- camel -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-reactive-executor-vertx</artifactId>
+ </dependency>
+
+ <!-- quarkus -->
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-vertx</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-bootstrap-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeRegistry.java b/extensions/reactive-executor/runtime/src/main/java/org/apache/camel/quarkus/reactive/executor/ReactiveExecutorRecorder.java
similarity index 61%
copy from extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeRegistry.java
copy to extensions/reactive-executor/runtime/src/main/java/org/apache/camel/quarkus/reactive/executor/ReactiveExecutorRecorder.java
index 9324e8e..ad0d15f 100644
--- a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeRegistry.java
+++ b/extensions/reactive-executor/runtime/src/main/java/org/apache/camel/quarkus/reactive/executor/ReactiveExecutorRecorder.java
@@ -14,20 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.core;
+package org.apache.camel.quarkus.reactive.executor;
import io.quarkus.runtime.RuntimeValue;
-import org.apache.camel.support.DefaultRegistry;
+import io.quarkus.runtime.annotations.Recorder;
+import io.vertx.core.Vertx;
+import org.apache.camel.reactive.vertx.VertXReactiveExecutor;
+import org.apache.camel.spi.ReactiveExecutor;
-public class RuntimeRegistry extends DefaultRegistry {
- public RuntimeRegistry() {
- super(new RuntimeBeanRepository());
- }
+@Recorder
+public class ReactiveExecutorRecorder {
+ public RuntimeValue<ReactiveExecutor> createReactiveExecutor(RuntimeValue<Vertx> vertx) {
+ VertXReactiveExecutor executor = new VertXReactiveExecutor();
+ executor.setVertx(vertx.getValue());
- @Override
- public Object unwrap(Object value) {
- return (value instanceof RuntimeValue)
- ? ((RuntimeValue)value).getValue()
- : value;
+ return new RuntimeValue<>(executor);
}
}
diff --git a/integration-tests/core-main/test/pom.xml b/integration-tests/core-main/test/pom.xml
index 5e079f0..f5668d5 100644
--- a/integration-tests/core-main/test/pom.xml
+++ b/integration-tests/core-main/test/pom.xml
@@ -32,6 +32,10 @@
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-reactive-executor</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-log</artifactId>
</dependency>
<dependency>
diff --git a/integration-tests/core-main/test/src/main/java/org/apache/camel/quarkus/core/CamelServlet.java b/integration-tests/core-main/test/src/main/java/org/apache/camel/quarkus/core/CamelServlet.java
index 4dd8876..014fee1 100644
--- a/integration-tests/core-main/test/src/main/java/org/apache/camel/quarkus/core/CamelServlet.java
+++ b/integration-tests/core-main/test/src/main/java/org/apache/camel/quarkus/core/CamelServlet.java
@@ -22,6 +22,7 @@ import javax.inject.Inject;
import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@@ -33,6 +34,8 @@ import org.apache.camel.CamelContext;
import org.apache.camel.ExtendedCamelContext;
import org.apache.camel.component.log.LogComponent;
import org.apache.camel.component.timer.TimerComponent;
+import org.apache.camel.reactive.vertx.VertXReactiveExecutor;
+import org.apache.camel.spi.ReactiveExecutor;
import org.apache.camel.spi.Registry;
import org.apache.camel.support.processor.DefaultExchangeFormatter;
@@ -123,7 +126,7 @@ public class CamelServlet {
main.getMainListeners().forEach(listener -> listeners.add(listener.getClass().getName()));
JsonArrayBuilder routeBuilders = Json.createArrayBuilder();
- main.getRouteBuilders().forEach(builder -> routeBuilders.add(builder.getClass().getName()));
+ main.getRoutesBuilders().forEach(builder -> routeBuilders.add(builder.getClass().getName()));
JsonArrayBuilder routes = Json.createArrayBuilder();
main.getCamelContext().getRoutes().forEach(route -> routes.add(route.getId()));
@@ -135,4 +138,21 @@ public class CamelServlet {
.add("autoConfigurationLogSummary", main.getMainConfigurationProperties().isAutoConfigurationLogSummary())
.build();
}
+
+ @Path("/context/reactive-executor")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public JsonObject reactiveExecutor() {
+ ReactiveExecutor executor = context.getReactiveExecutor();
+
+ JsonObjectBuilder builder = Json.createObjectBuilder();
+ builder.add("class", executor.getClass().getName());
+
+ if (executor instanceof VertXReactiveExecutor) {
+ builder.add("configured", ((VertXReactiveExecutor)executor).getVertx() != null);
+
+ }
+
+ return builder.build();
+ }
}
diff --git a/integration-tests/core-main/test/src/test/java/org/apache/camel/quarkus/core/CamelTest.java b/integration-tests/core-main/test/src/test/java/org/apache/camel/quarkus/core/CamelTest.java
index bb2e1de..5e353cc 100644
--- a/integration-tests/core-main/test/src/test/java/org/apache/camel/quarkus/core/CamelTest.java
+++ b/integration-tests/core-main/test/src/test/java/org/apache/camel/quarkus/core/CamelTest.java
@@ -25,6 +25,7 @@ import io.restassured.http.ContentType;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
import org.apache.camel.quarkus.core.runtime.support.SupportListener;
+import org.apache.camel.reactive.vertx.VertXReactiveExecutor;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@@ -80,4 +81,17 @@ public class CamelTest {
assertThat(p.getBoolean("autoConfigurationLogSummary")).isFalse();
}
+
+ @Test
+ public void testReactiveExecutor() {
+ JsonPath executor = RestAssured.when().get("/test/context/reactive-executor")
+ .then()
+ .statusCode(200)
+ .extract()
+ .body()
+ .jsonPath();
+
+ assertThat(executor.getString("class")).isEqualTo(VertXReactiveExecutor.class.getName());
+ assertThat(executor.getBoolean("configured")).isTrue();
+ }
}
diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml
index c0c1090..35c0d8f 100644
--- a/poms/bom-deployment/pom.xml
+++ b/poms/bom-deployment/pom.xml
@@ -162,6 +162,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-reactive-executor-deployment</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-rest-deployment</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index 50cc881..7930c40 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -193,6 +193,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-reactive-executor-vertx</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-salesforce</artifactId>
<version>${camel.version}</version>
</dependency>
@@ -334,6 +339,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-reactive-executor</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-rest</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>