This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
View the commit online: https://github.com/apache/camel-quarkus/commit/9bbab37c54cedb64666643a0e3c45313cb91571d The following commit(s) were added to refs/heads/master by this push: new 9bbab37 Add Hystirx component extension (#449) 9bbab37 is described below commit 9bbab37c54cedb64666643a0e3c45313cb91571d Author: James Netherton <jamesnether...@users.noreply.github.com> AuthorDate: Wed Nov 20 21:07:21 2019 +0000 Add Hystirx component extension (#449) fixes #429 --- .../quarkus/QuarkusRuntimeProviderTest.java | 1 - .../pages/list-of-camel-quarkus-extensions.adoc | 4 +- extensions/hystrix/deployment/pom.xml | 75 ++++++++++++ .../hystrix/deployment/HystrixProcessor.java | 56 +++++++++ extensions/hystrix/pom.xml | 39 ++++++ extensions/hystrix/runtime/pom.xml | 86 +++++++++++++ .../hystrix/graal/SubstituteConfigJMXManager.java | 38 ++++++ .../graal/SubstituteRxJavaUnsafeAccess.java | 29 +++++ .../main/resources/META-INF/quarkus-extension.yaml | 27 ++++ extensions/pom.xml | 1 + extensions/readme.adoc | 4 +- integration-tests/hystrix/pom.xml | 136 +++++++++++++++++++++ .../component/hystrix/it/HystrixResource.java | 51 ++++++++ .../component/hystrix/it/HystrixRoutes.java | 49 ++++++++ .../quarkus/component/hystrix/it/HystrixIT.java | 24 ++++ .../quarkus/component/hystrix/it/HystrixTest.java | 52 ++++++++ integration-tests/pom.xml | 1 + poms/bom-deployment/pom.xml | 5 + poms/bom/pom.xml | 10 ++ 19 files changed, 685 insertions(+), 3 deletions(-) diff --git a/catalog/camel-quarkus-catalog/src/test/java/org/apache/camel/catalog/quarkus/QuarkusRuntimeProviderTest.java b/catalog/camel-quarkus-catalog/src/test/java/org/apache/camel/catalog/quarkus/QuarkusRuntimeProviderTest.java index ea58a68..0e2c8ae 100644 --- a/catalog/camel-quarkus-catalog/src/test/java/org/apache/camel/catalog/quarkus/QuarkusRuntimeProviderTest.java +++ b/catalog/camel-quarkus-catalog/src/test/java/org/apache/camel/catalog/quarkus/QuarkusRuntimeProviderTest.java @@ -115,7 +115,6 @@ public class QuarkusRuntimeProviderTest { assertTrue(names.contains("reactive-executor-vertx")); assertFalse(names.contains("blueprint")); - assertFalse(names.contains("hystrix")); } @Test diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc index 53f155b..2097a26 100644 --- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc +++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc @@ -195,7 +195,7 @@ Number of Camel languages: 8 in 2 JAR artifacts (0 deprecated) == Miscellaneous Extensions // others: START -Number of miscellaneous extensions: 7 in 7 JAR artifacts (0 deprecated) +Number of miscellaneous extensions: 8 in 8 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -209,6 +209,8 @@ Number of miscellaneous extensions: 7 in 7 JAR artifacts (0 deprecated) | (camel-quarkus-core-xml) | 0.3 | Includes implementations of Java Architecture for XML Binding (JAXB) and Java API for XML Processing (JAXP) +| (camel-quarkus-hystrix) | 0.5 | Circuit Breaker EIP using Netflix Hystrix + | xref:extensions/microprofile-health.adoc[camel-quarkus-microprofile-health] | 0.3 | Bridging Eclipse MicroProfile Health with Camel health checks | xref:extensions/opentracing.adoc[camel-quarkus-opentracing] | 0.3 | Distributed tracing using OpenTracing diff --git a/extensions/hystrix/deployment/pom.xml b/extensions/hystrix/deployment/pom.xml new file mode 100644 index 0000000..2c4eb4d --- /dev/null +++ b/extensions/hystrix/deployment/pom.xml @@ -0,0 +1,75 @@ +<?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-hystrix-parent</artifactId> + <version>0.4.1-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-hystrix-deployment</artifactId> + <name>Camel Quarkus :: Hystrix :: 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-hystrix</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/hystrix/deployment/src/main/java/org/apache/camel/quarkus/component/hystrix/deployment/HystrixProcessor.java b/extensions/hystrix/deployment/src/main/java/org/apache/camel/quarkus/component/hystrix/deployment/HystrixProcessor.java new file mode 100644 index 0000000..bbb2e83 --- /dev/null +++ b/extensions/hystrix/deployment/src/main/java/org/apache/camel/quarkus/component/hystrix/deployment/HystrixProcessor.java @@ -0,0 +1,56 @@ +/* + * 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. + */ +package org.apache.camel.quarkus.component.hystrix.deployment; + +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; +import io.quarkus.deployment.builditem.nativeimage.NativeImageSystemPropertyBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; + +import org.apache.camel.model.HystrixConfigurationCommon; +import org.apache.camel.model.HystrixConfigurationDefinition; +import org.apache.camel.model.HystrixDefinition; +import org.apache.camel.model.OnFallbackDefinition; + +class HystrixProcessor { + + private static final String FEATURE = "camel-hystrix"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, + BuildProducer<NativeImageResourceBuildItem> resource, + BuildProducer<NativeImageSystemPropertyBuildItem> systemProperty) { + + reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, + HystrixConfigurationCommon.class, + HystrixConfigurationDefinition.class, + HystrixDefinition.class, + OnFallbackDefinition.class)); + + resource.produce(new NativeImageResourceBuildItem("META-INF/services/org/apache/camel/model/HystrixDefinition")); + + // Force RxJava to not use Unsafe API + systemProperty.produce(new NativeImageSystemPropertyBuildItem("rx.unsafe-disable", "true")); + } +} diff --git a/extensions/hystrix/pom.xml b/extensions/hystrix/pom.xml new file mode 100644 index 0000000..32210c5 --- /dev/null +++ b/extensions/hystrix/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"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-build-parent</artifactId> + <version>0.4.1-SNAPSHOT</version> + <relativePath>../../poms/build-parent/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-hystrix-parent</artifactId> + <name>Camel Quarkus :: Hystrix</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions/hystrix/runtime/pom.xml b/extensions/hystrix/runtime/pom.xml new file mode 100644 index 0000000..645d133 --- /dev/null +++ b/extensions/hystrix/runtime/pom.xml @@ -0,0 +1,86 @@ +<?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-hystrix-parent</artifactId> + <version>0.4.1-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-hystrix</artifactId> + <name>Camel Quarkus :: Hystrix :: Runtime</name> + + <properties> + <firstVersion>0.5.0</firstVersion> + </properties> + + <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> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-hystrix</artifactId> + </dependency> + <dependency> + <groupId>com.oracle.substratevm</groupId> + <artifactId>svm</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/hystrix/runtime/src/main/java/org/apache/camel/quarkus/component/hystrix/graal/SubstituteConfigJMXManager.java b/extensions/hystrix/runtime/src/main/java/org/apache/camel/quarkus/component/hystrix/graal/SubstituteConfigJMXManager.java new file mode 100644 index 0000000..29afe09 --- /dev/null +++ b/extensions/hystrix/runtime/src/main/java/org/apache/camel/quarkus/component/hystrix/graal/SubstituteConfigJMXManager.java @@ -0,0 +1,38 @@ +/* + * 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. + */ +package org.apache.camel.quarkus.component.hystrix.graal; + +import com.netflix.config.jmx.ConfigMBean; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; + +import org.apache.commons.configuration.AbstractConfiguration; + +@TargetClass(className = "com.netflix.config.jmx.ConfigJMXManager") +public final class SubstituteConfigJMXManager { + + @Substitute + public static ConfigMBean registerConfigMbean(AbstractConfiguration config) { + return null; + } + + @Substitute + public static void unRegisterConfigMBean(AbstractConfiguration config, ConfigMBean mbean) { + // Noop + } + +} diff --git a/extensions/hystrix/runtime/src/main/java/org/apache/camel/quarkus/component/hystrix/graal/SubstituteRxJavaUnsafeAccess.java b/extensions/hystrix/runtime/src/main/java/org/apache/camel/quarkus/component/hystrix/graal/SubstituteRxJavaUnsafeAccess.java new file mode 100644 index 0000000..d4c692f --- /dev/null +++ b/extensions/hystrix/runtime/src/main/java/org/apache/camel/quarkus/component/hystrix/graal/SubstituteRxJavaUnsafeAccess.java @@ -0,0 +1,29 @@ +/* + * 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. + */ +package org.apache.camel.quarkus.component.hystrix.graal; + +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; + +@TargetClass(className = "rx.internal.util.unsafe.UnsafeAccess") +public final class SubstituteRxJavaUnsafeAccess { + + @Substitute + public static boolean isUnsafeAvailable() { + return false; + } +} diff --git a/extensions/hystrix/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/hystrix/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..66199a8 --- /dev/null +++ b/extensions/hystrix/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,27 @@ +# +# 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. +# + +--- +name: "Camel Quarkus Hystrix" +description: "Camel Hystrix support" +metadata: + keywords: + - "camel" + - "hystrix" + guide: "https://quarkus.io/guides/camel" + categories: + - "integration" \ No newline at end of file diff --git a/extensions/pom.xml b/extensions/pom.xml index fed1366..2ea812c 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -58,6 +58,7 @@ <module>exec</module> <module>fhir</module> <module>file</module> + <module>hystrix</module> <module>infinispan</module> <module>jackson</module> <module>jdbc</module> diff --git a/extensions/readme.adoc b/extensions/readme.adoc index 539d09c..ce94d79 100644 --- a/extensions/readme.adoc +++ b/extensions/readme.adoc @@ -197,7 +197,7 @@ Number of Camel languages: 8 in 2 JAR artifacts (0 deprecated) == Miscellaneous Extensions // others: START -Number of miscellaneous extensions: 7 in 7 JAR artifacts (0 deprecated) +Number of miscellaneous extensions: 8 in 8 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -211,6 +211,8 @@ Number of miscellaneous extensions: 7 in 7 JAR artifacts (0 deprecated) | (camel-quarkus-core-xml) | 0.3 | Includes implementations of Java Architecture for XML Binding (JAXB) and Java API for XML Processing (JAXP) +| (camel-quarkus-hystrix) | 0.5 | Circuit Breaker EIP using Netflix Hystrix + | xref:extensions/microprofile-health.adoc[camel-quarkus-microprofile-health] | 0.3 | Bridging Eclipse MicroProfile Health with Camel health checks | xref:extensions/opentracing.adoc[camel-quarkus-opentracing] | 0.3 | Distributed tracing using OpenTracing diff --git a/integration-tests/hystrix/pom.xml b/integration-tests/hystrix/pom.xml new file mode 100644 index 0000000..6d3c01d --- /dev/null +++ b/integration-tests/hystrix/pom.xml @@ -0,0 +1,136 @@ +<?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-integration-tests</artifactId> + <version>0.4.1-SNAPSHOT</version> + </parent> + + <artifactId>camel-quarkus-integration-test-hystrix</artifactId> + <name>Camel Quarkus :: Integration Tests :: Hystrix</name> + <description>Integration tests for Camel Quarkus Hystrix extension</description> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-hystrix</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-netty-http</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> + </dependency> + + <!-- test dependencies --> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>rest-assured</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>build</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <profiles> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + <configuration> + <systemProperties> + <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> + </systemProperties> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <executions> + <execution> + <id>native-image</id> + <goals> + <goal>native-image</goal> + </goals> + <configuration> + <reportErrorsAtRuntime>false</reportErrorsAtRuntime> + <cleanupServer>true</cleanupServer> + <enableHttpsUrlHandler>true</enableHttpsUrlHandler> + <enableServer>false</enableServer> + <dumpProxies>false</dumpProxies> + <graalvmHome>${graalvmHome}</graalvmHome> + <enableJni>true</enableJni> + <enableAllSecurityServices>true</enableAllSecurityServices> + <disableReports>true</disableReports> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> + +</project> diff --git a/integration-tests/hystrix/src/main/java/org/apache/camel/quarkus/component/hystrix/it/HystrixResource.java b/integration-tests/hystrix/src/main/java/org/apache/camel/quarkus/component/hystrix/it/HystrixResource.java new file mode 100644 index 0000000..5e6a9df --- /dev/null +++ b/integration-tests/hystrix/src/main/java/org/apache/camel/quarkus/component/hystrix/it/HystrixResource.java @@ -0,0 +1,51 @@ +/* + * 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. + */ +package org.apache.camel.quarkus.component.hystrix.it; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.apache.camel.ProducerTemplate; + +@Path("/hystrix") +@ApplicationScoped +public class HystrixResource { + + @Inject + ProducerTemplate producerTemplate; + + @Path("/fallback/delay/{delayMilliseconds}") + @GET + @Produces(MediaType.TEXT_PLAIN) + public String hystrixFallbackWithDelay(@PathParam("delayMilliseconds") long delayMilliseconds) throws Exception { + return producerTemplate.requestBodyAndHeader("direct:fallback", null, "delayMilliseconds", delayMilliseconds, + String.class); + } + + @Path("/fallback/network") + @GET + @Produces(MediaType.TEXT_PLAIN) + public String hystrixFallbackViaNetwork() throws Exception { + return producerTemplate.requestBody("direct:fallbackViaNetwork", null, String.class); + } + +} diff --git a/integration-tests/hystrix/src/main/java/org/apache/camel/quarkus/component/hystrix/it/HystrixRoutes.java b/integration-tests/hystrix/src/main/java/org/apache/camel/quarkus/component/hystrix/it/HystrixRoutes.java new file mode 100644 index 0000000..80c5d82 --- /dev/null +++ b/integration-tests/hystrix/src/main/java/org/apache/camel/quarkus/component/hystrix/it/HystrixRoutes.java @@ -0,0 +1,49 @@ +/* + * 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. + */ +package org.apache.camel.quarkus.component.hystrix.it; + +import org.apache.camel.builder.RouteBuilder; + +public class HystrixRoutes extends RouteBuilder { + + @Override + public void configure() throws Exception { + from("direct:fallback") + .hystrix() + .hystrixConfiguration() + .executionTimeoutInMilliseconds(100) + .end() + .to("direct:delay") + .onFallback() + .setBody(constant("Fallback response")) + .end(); + + from("direct:fallbackViaNetwork") + .hystrix() + .throwException(new IllegalStateException("Forced exception")) + .onFallbackViaNetwork() + .to("netty-http:http://localhost:8999/network/fallback") + .end(); + + from("direct:delay") + .delay(simple("${header.delayMilliseconds}")) + .setBody(constant("Hello Camel Quarkus Hystrix")); + + from("netty-http:http://0.0.0.0:8999/network/fallback") + .setBody(constant("Fallback via network response")); + } +} diff --git a/integration-tests/hystrix/src/test/java/org/apache/camel/quarkus/component/hystrix/it/HystrixIT.java b/integration-tests/hystrix/src/test/java/org/apache/camel/quarkus/component/hystrix/it/HystrixIT.java new file mode 100644 index 0000000..6eb4115 --- /dev/null +++ b/integration-tests/hystrix/src/test/java/org/apache/camel/quarkus/component/hystrix/it/HystrixIT.java @@ -0,0 +1,24 @@ +/* + * 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. + */ +package org.apache.camel.quarkus.component.hystrix.it; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +class HystrixIT extends HystrixTest { + +} diff --git a/integration-tests/hystrix/src/test/java/org/apache/camel/quarkus/component/hystrix/it/HystrixTest.java b/integration-tests/hystrix/src/test/java/org/apache/camel/quarkus/component/hystrix/it/HystrixTest.java new file mode 100644 index 0000000..6056c81 --- /dev/null +++ b/integration-tests/hystrix/src/test/java/org/apache/camel/quarkus/component/hystrix/it/HystrixTest.java @@ -0,0 +1,52 @@ +/* + * 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. + */ +package org.apache.camel.quarkus.component.hystrix.it; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; + +import org.junit.jupiter.api.Test; +import static org.hamcrest.core.Is.is; + +@QuarkusTest +class HystrixTest { + + @Test + public void testHystrixFallback() { + + // Try a 10 millisecond delay in route processing to be within the allowed circuit breaker tolerance + RestAssured.get("/hystrix/fallback/delay/10") + .then() + .statusCode(200) + .body(is("Hello Camel Quarkus Hystrix")); + + // Try an unacceptable delay to trigger the fallback response + RestAssured.get("/hystrix/fallback/delay/110") + .then() + .statusCode(200) + .body(is("Fallback response")); + } + + @Test + public void testHystrixFallbackViaNetwork() { + + RestAssured.get("/hystrix/fallback/network") + .then() + .statusCode(200) + .body(is("Fallback via network response")); + } +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index ec0dff5..689e5f0 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -84,6 +84,7 @@ <module>exec</module> <module>fhir</module> <module>file</module> + <module>hystrix</module> <module>infinispan</module> <module>jackson</module> <module>jdbc</module> diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml index c02b3a7..f6d242b 100644 --- a/poms/bom-deployment/pom.xml +++ b/poms/bom-deployment/pom.xml @@ -190,6 +190,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-hystrix-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-kafka-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 2d53686..52bd846 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -176,6 +176,11 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-hystrix</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-infinispan</artifactId> <version>${camel.version}</version> <exclusions> @@ -485,6 +490,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-hystrix</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-infinispan</artifactId> <version>${camel-quarkus.version}</version> </dependency>