diff --git a/docs/modules/ROOT/examples/components/activemq.yml b/docs/modules/ROOT/examples/components/activemq.yml new file mode 100644 index 000000000000..e1fbbf302b45 --- /dev/null +++ b/docs/modules/ROOT/examples/components/activemq.yml @@ -0,0 +1,13 @@ +# Do not edit directly! +# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page +cqArtifactId: camel-quarkus-activemq +cqArtifactIdBase: activemq +cqNativeSupported: true +cqStatus: Stable +cqDeprecated: false +cqJvmSince: 1.0.0 +cqNativeSince: 1.0.0 +cqCamelPartName: activemq +cqCamelPartTitle: ActiveMQ +cqCamelPartDescription: Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS component. +cqExtensionPageTitle: ActiveMQ diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index d723a520204a..e39893ee193f 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -50,6 +50,7 @@ *** xref:reference/extensions/aws2-translate.adoc[AWS 2 Translate] *** xref:reference/extensions/aws-secrets-manager.adoc[AWS Secrets Manager] *** xref:reference/extensions/aws-xray.adoc[AWS XRay] +*** xref:reference/extensions/activemq.adoc[ActiveMQ] *** xref:reference/extensions/arangodb.adoc[ArangoDb] *** xref:reference/extensions/asterisk.adoc[Asterisk] *** xref:reference/extensions/atlasmap.adoc[AtlasMap] diff --git a/docs/modules/ROOT/pages/reference/extensions/activemq.adoc b/docs/modules/ROOT/pages/reference/extensions/activemq.adoc new file mode 100644 index 000000000000..068614c7c58c --- /dev/null +++ b/docs/modules/ROOT/pages/reference/extensions/activemq.adoc @@ -0,0 +1,87 @@ +// Do not edit directly! +// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page +[id="extensions-activemq"] += ActiveMQ +:page-aliases: extensions/activemq.adoc +:linkattrs: +:cq-artifact-id: camel-quarkus-activemq +:cq-native-supported: true +:cq-status: Stable +:cq-status-deprecation: Stable +:cq-description: Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS component. +:cq-deprecated: false +:cq-jvm-since: 1.0.0 +:cq-native-since: 1.0.0 + +ifeval::[{doc-show-badges} == true] +[.badges] +[.badge-key]##JVM since##[.badge-supported]##1.0.0## [.badge-key]##Native since##[.badge-supported]##1.0.0## +endif::[] + +Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS component. + +[id="extensions-activemq-whats-inside"] +== What's inside + +* xref:{cq-camel-components}::activemq-component.adoc[ActiveMQ component], URI syntax: `activemq:destinationType:destinationName` + +Please refer to the above link for usage and configuration details. + +[id="extensions-activemq-maven-coordinates"] +== Maven coordinates + +https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-activemq[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"] + +Or add the coordinates to your existing project: + +[source,xml] +---- + + org.apache.camel.quarkus + camel-quarkus-activemq + +---- +ifeval::[{doc-show-user-guide-link} == true] +Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications. +endif::[] + +[id="extensions-activemq-usage"] +== Usage +[id="extensions-activemq-usage-message-mapping-with-org-w3c-dom-node"] +=== Message mapping with `org.w3c.dom.Node` + +The Camel ActiveMQ component supports message mapping between `javax.jms.Message` and `org.apache.camel.Message`. When wanting to convert a Camel message body type of `org.w3c.dom.Node`, +you must ensure that the `camel-quarkus-xml-jaxp` extension is present on the classpath. + +[id="extensions-activemq-usage-native-mode-support-for-javax-jms-objectmessage"] +=== Native mode support for javax.jms.ObjectMessage + +When sending JMS message payloads as `javax.jms.ObjectMessage`, you must annotate the relevant classes to be registered for serialization with `@RegisterForReflection(serialization = true)`. +Note that this extension automatically sets `quarkus.camel.native.reflection.serialization-enabled = true` for you. Refer to the xref:user-guide/native-mode.adoc#serialization[native mode user guide] for more information. + + +[id="extensions-activemq-camel-quarkus-limitations"] +== Camel Quarkus limitations + +ActiveMQ https://activemq.apache.org/selectors.html[XPath selectors] are disabled in native mode as the functionality depends on `activemq-broker`. This dependency +is excluded from the dependency tree, since none of the ActiveMQ broker functionality is supported in native mode. + + +[id="extensions-activemq-ssl-in-native-mode"] +== SSL in native mode + +This extension auto-enables SSL support in native mode. Hence you do not need to add +`quarkus.ssl.native=true` to your `application.properties` yourself. See also +https://quarkus.io/guides/native-and-ssl[Quarkus SSL guide]. + +[id="extensions-activemq-transferexception-option-in-native-mode"] +== transferException option in native mode + +To use the `transferException` option in native mode, you must enable support for object serialization. Refer to the xref:user-guide/native-mode.adoc#serialization[native mode user guide] +for more information. + +You will also need to enable serialization for the exception classes that you intend to serialize. For example. +[source,java] +---- +@RegisterForReflection(targets = { IllegalStateException.class, MyCustomException.class }, serialization = true) +---- diff --git a/extensions/activemq/deployment/pom.xml b/extensions/activemq/deployment/pom.xml new file mode 100644 index 000000000000..66faec53dc20 --- /dev/null +++ b/extensions/activemq/deployment/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.camel.quarkus + camel-quarkus-activemq-parent + 3.0.0-SNAPSHOT + ../pom.xml + + + camel-quarkus-activemq-deployment + Camel Quarkus :: ActiveMQ :: Deployment + + + + org.apache.camel.quarkus + camel-quarkus-core-deployment + + + org.apache.camel.quarkus + camel-quarkus-jms-deployment + + + org.apache.camel.quarkus + camel-quarkus-activemq + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${quarkus.version} + + + + + + + + diff --git a/extensions/activemq/deployment/src/main/java/org/apache/camel/quarkus/component/activemq/deployment/ActiveMQProcessor.java b/extensions/activemq/deployment/src/main/java/org/apache/camel/quarkus/component/activemq/deployment/ActiveMQProcessor.java new file mode 100644 index 000000000000..da3074dbadad --- /dev/null +++ b/extensions/activemq/deployment/src/main/java/org/apache/camel/quarkus/component/activemq/deployment/ActiveMQProcessor.java @@ -0,0 +1,141 @@ +/* + * 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.activemq.deployment; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Collection; +import java.util.Properties; +import java.util.stream.Stream; + +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.CombinedIndexBuildItem; +import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.IndexDependencyBuildItem; +import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem; +import org.apache.activemq.transport.Transport; +import org.apache.activemq.transport.discovery.DiscoveryAgent; +import org.apache.activemq.util.IdGenerator; +import org.apache.activemq.wireformat.WireFormatFactory; +import org.jboss.jandex.ClassInfo; +import org.jboss.jandex.DotName; +import org.jboss.jandex.IndexView; + +class ActiveMQProcessor { + + private static final String ACTIVEMQ_SERVICE_BASE = "META-INF/services/org/apache/activemq/"; + private static final String FEATURE = "camel-activemq"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + ExtensionSslNativeSupportBuildItem activateSslNativeSupport() { + return new ExtensionSslNativeSupportBuildItem(FEATURE); + } + + @BuildStep + void reflectiveClasses( + CombinedIndexBuildItem combinedIndex, + BuildProducer reflectiveClasses) { + + reflectiveClasses.produce( + ReflectiveClassBuildItem.builder( + java.net.Socket.class.getName(), + "sun.security.ssl.SSLSocketImpl", + org.apache.activemq.ActiveMQConnectionFactory.class.getName(), + org.apache.activemq.ActiveMQPrefetchPolicy.class.getName(), + org.apache.activemq.RedeliveryPolicy.class.getName(), + org.apache.activemq.blob.BlobTransferPolicy.class.getName(), + org.apache.activemq.command.ConsumerInfo.class.getName(), + org.apache.activemq.openwire.v9.MarshallerFactory.class.getName(), + org.apache.activemq.openwire.v10.MarshallerFactory.class.getName(), + org.apache.activemq.openwire.v11.MarshallerFactory.class.getName(), + org.apache.activemq.openwire.v12.MarshallerFactory.class.getName()) + .methods() + .build()); + + final IndexView index = combinedIndex.getIndex(); + + reflectiveClasses.produce( + ReflectiveClassBuildItem.builder( + Stream.of(Transport.class, WireFormatFactory.class, DiscoveryAgent.class) + .map(DotName::createSimple) + .map(index::getAllKnownImplementors) + .flatMap(Collection::stream) + .map(ClassInfo::name) + .map(DotName::toString) + .toArray(String[]::new)) + .methods() + .build()); + } + + @BuildStep + void addDependencies(BuildProducer indexDependency) { + indexDependency.produce(new IndexDependencyBuildItem("org.apache.activemq", "activemq-client-jakarta")); + } + + @BuildStep + void registerServiceProviders(BuildProducer reflectiveClass, + BuildProducer nativeImage) { + + String[] servicePaths = new String[] { + ACTIVEMQ_SERVICE_BASE + "transport/discoveryagent/masterslave", + ACTIVEMQ_SERVICE_BASE + "transport/discoveryagent/multicast", + ACTIVEMQ_SERVICE_BASE + "transport/discoveryagent/simple", + ACTIVEMQ_SERVICE_BASE + "transport/discoveryagent/static", + ACTIVEMQ_SERVICE_BASE + "transport/failover", + ACTIVEMQ_SERVICE_BASE + "transport/fanout", + ACTIVEMQ_SERVICE_BASE + "transport/mock", + ACTIVEMQ_SERVICE_BASE + "transport/multicast", + ACTIVEMQ_SERVICE_BASE + "transport/nio", + ACTIVEMQ_SERVICE_BASE + "transport/nio+ssl", + ACTIVEMQ_SERVICE_BASE + "transport/ssl", + ACTIVEMQ_SERVICE_BASE + "transport/tcp", + ACTIVEMQ_SERVICE_BASE + "transport/udp", + ACTIVEMQ_SERVICE_BASE + "wireformat/default", + }; + + for (String path : servicePaths) { + reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, getServiceClass(path))); + } + + nativeImage.produce(new NativeImageResourceBuildItem(servicePaths)); + } + + @BuildStep + void runtimeReinitializedClasses(BuildProducer runtimeReInitializedClass) { + runtimeReInitializedClass.produce(new RuntimeReinitializedClassBuildItem(IdGenerator.class.getName())); + } + + private String getServiceClass(String servicePath) { + try (InputStream resource = ActiveMQProcessor.class.getClassLoader().getResourceAsStream(servicePath)) { + Properties properties = new Properties(); + properties.load(resource); + return properties.getProperty("class"); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + +} diff --git a/extensions/activemq/pom.xml b/extensions/activemq/pom.xml new file mode 100644 index 000000000000..4134d1ff38fe --- /dev/null +++ b/extensions/activemq/pom.xml @@ -0,0 +1,37 @@ + + + + 4.0.0 + + org.apache.camel.quarkus + camel-quarkus-extensions + 3.0.0-SNAPSHOT + ../pom.xml + + + camel-quarkus-activemq-parent + Camel Quarkus :: ActiveMQ + pom + + + deployment + runtime + + diff --git a/extensions/activemq/runtime/pom.xml b/extensions/activemq/runtime/pom.xml new file mode 100644 index 000000000000..b6a13ba58d69 --- /dev/null +++ b/extensions/activemq/runtime/pom.xml @@ -0,0 +1,110 @@ + + + + 4.0.0 + + org.apache.camel.quarkus + camel-quarkus-activemq-parent + 3.0.0-SNAPSHOT + ../pom.xml + + + camel-quarkus-activemq + Camel Quarkus :: ActiveMQ :: Runtime + + + 1.0.0 + 1.0.0 + + + + + org.apache.camel.quarkus + camel-quarkus-core + + + org.apache.camel.quarkus + camel-quarkus-jms + + + org.apache.camel + camel-activemq + + + jakarta.jms + jakarta.jms-api + + + org.graalvm.nativeimage + svm + provided + + + + + + + io.quarkus + quarkus-extension-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${quarkus.version} + + + + + + + + + + full + + + !quickly + + + + + + org.apache.camel.quarkus + camel-quarkus-maven-plugin + + + update-extension-doc-page + + update-extension-doc-page + + process-classes + + + + + + + + diff --git a/extensions/activemq/runtime/src/main/doc/limitations.adoc b/extensions/activemq/runtime/src/main/doc/limitations.adoc new file mode 100644 index 000000000000..1a8b4f7a6084 --- /dev/null +++ b/extensions/activemq/runtime/src/main/doc/limitations.adoc @@ -0,0 +1,2 @@ +ActiveMQ https://activemq.apache.org/selectors.html[XPath selectors] are disabled in native mode as the functionality depends on `activemq-broker`. This dependency +is excluded from the dependency tree, since none of the ActiveMQ broker functionality is supported in native mode. diff --git a/extensions/activemq/runtime/src/main/doc/usage.adoc b/extensions/activemq/runtime/src/main/doc/usage.adoc new file mode 100644 index 000000000000..3fd59c5fa58b --- /dev/null +++ b/extensions/activemq/runtime/src/main/doc/usage.adoc @@ -0,0 +1,9 @@ +=== Message mapping with `org.w3c.dom.Node` + +The Camel ActiveMQ component supports message mapping between `javax.jms.Message` and `org.apache.camel.Message`. When wanting to convert a Camel message body type of `org.w3c.dom.Node`, +you must ensure that the `camel-quarkus-xml-jaxp` extension is present on the classpath. + +=== Native mode support for javax.jms.ObjectMessage + +When sending JMS message payloads as `javax.jms.ObjectMessage`, you must annotate the relevant classes to be registered for serialization with `@RegisterForReflection(serialization = true)`. +Note that this extension automatically sets `quarkus.camel.native.reflection.serialization-enabled = true` for you. Refer to the xref:user-guide/native-mode.adoc#serialization[native mode user guide] for more information. diff --git a/extensions/activemq/runtime/src/main/java/org/apache/camel/quarkus/component/activemq/graal/ActiveMQSubstitutions.java b/extensions/activemq/runtime/src/main/java/org/apache/camel/quarkus/component/activemq/graal/ActiveMQSubstitutions.java new file mode 100644 index 000000000000..b9fd5fc1254a --- /dev/null +++ b/extensions/activemq/runtime/src/main/java/org/apache/camel/quarkus/component/activemq/graal/ActiveMQSubstitutions.java @@ -0,0 +1,43 @@ +/* + * 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.activemq.graal; + +import com.oracle.svm.core.annotate.Delete; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; +import org.apache.activemq.filter.BooleanExpression; +import org.apache.activemq.filter.UnaryExpression; +import org.apache.activemq.filter.XPathExpression; + +final class ActiveMQSubstitutions { +} + +@TargetClass(XPathExpression.class) +@Delete +final class SubstituteXPathExpression { +} + +@TargetClass(UnaryExpression.class) +final class SubstituteUnaryExpression { + + @Substitute + public static BooleanExpression createXPath(final String xpath) { + // The required dependencies to make this work are not on the classpath by default + // Since this appears to be a somewhat niche feature for Camel, it is not supported in native mode + throw new RuntimeException("XPath selectors are not supported in native mode"); + } +} diff --git a/extensions/activemq/runtime/src/main/java/org/apache/camel/quarkus/component/activemq/graal/SpringJMSSubstitutions.java b/extensions/activemq/runtime/src/main/java/org/apache/camel/quarkus/component/activemq/graal/SpringJMSSubstitutions.java new file mode 100644 index 000000000000..a3df08e09ae8 --- /dev/null +++ b/extensions/activemq/runtime/src/main/java/org/apache/camel/quarkus/component/activemq/graal/SpringJMSSubstitutions.java @@ -0,0 +1,89 @@ +/* + * 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.activemq.graal; + +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; +import jakarta.jms.Destination; +import jakarta.jms.JMSException; +import jakarta.jms.Message; +import jakarta.jms.MessageConsumer; +import jakarta.jms.MessageProducer; +import jakarta.jms.Session; +import jakarta.jms.Topic; +import org.springframework.jms.core.JmsTemplate; +import org.springframework.jms.listener.AbstractMessageListenerContainer; + +/** + * ActiveMQ is tied to JMS 1.1, so we need to disable any code paths in Spring JMS that try to leverage JMS 2.x APIs + */ +final class SpringJMSSubstitutions { +} + +@TargetClass(AbstractMessageListenerContainer.class) +final class SubstituteAbstractMessageListenerContainer { + + @Alias + private String subscriptionName; + @Alias + private volatile String messageSelector; + @Alias + private boolean pubSubDomain; + @Alias + private boolean subscriptionDurable; + @Alias + private boolean pubSubNoLocal; + + @Substitute + protected MessageConsumer createConsumer(Session session, Destination destination) throws JMSException { + // Removes references to JMS 2.0 shared subscriptions + if (pubSubDomain && destination instanceof Topic) { + if (subscriptionDurable) { + return session.createDurableSubscriber( + (Topic) destination, subscriptionName, messageSelector, pubSubNoLocal); + } else { + return session.createConsumer(destination, messageSelector, pubSubNoLocal); + } + } else { + return session.createConsumer(destination, messageSelector); + } + } +} + +@TargetClass(JmsTemplate.class) +final class SubstituteJmsTemplate { + + @Alias + private boolean explicitQosEnabled; + @Alias + private int deliveryMode; + @Alias + private int priority; + @Alias + private long timeToLive; + + @Substitute + protected void doSend(MessageProducer producer, Message message) throws JMSException { + // Removes references to JMS 2.0 delivery delay lookup + if (explicitQosEnabled) { + producer.send(message, deliveryMode, priority, timeToLive); + } else { + producer.send(message); + } + } +} diff --git a/extensions/activemq/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/activemq/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 000000000000..d1aae6a20968 --- /dev/null +++ b/extensions/activemq/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,31 @@ +# +# 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. +# + +# This is a generated file. Do not edit directly! +# To re-generate, run the following command from the top level directory: +# +# mvn -N cq:update-quarkus-metadata +# +--- +name: "Camel ActiveMQ" +description: "Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS component" +metadata: + guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/activemq.html" + categories: + - "integration" + status: + - "stable" diff --git a/extensions/pom.xml b/extensions/pom.xml index 4fb55e069ddc..bf80304b2ed7 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -34,6 +34,7 @@ + activemq amqp arangodb as2 diff --git a/integration-tests/activemq/pom.xml b/integration-tests/activemq/pom.xml new file mode 100644 index 000000000000..da352f63c904 --- /dev/null +++ b/integration-tests/activemq/pom.xml @@ -0,0 +1,154 @@ + + + + 4.0.0 + + org.apache.camel.quarkus + camel-quarkus-build-parent-it + 3.0.0-SNAPSHOT + ../../poms/build-parent-it/pom.xml + + + camel-quarkus-integration-test-activemq + Camel Quarkus :: Integration Tests :: ActiveMQ + Integration tests for Camel Quarkus ActiveMQ extension + + + + + org.apache.camel.quarkus + camel-quarkus-activemq + + + + + org.apache.camel.quarkus + camel-quarkus-integration-test-messaging-jms + + + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + org.testcontainers + testcontainers + test + + + junit + junit + + + + + io.quarkus + quarkus-junit4-mock + test + + + + + org.apache.camel.quarkus + camel-quarkus-integration-test-messaging-common + test-jar + test + + + org.apache.camel.quarkus + camel-quarkus-integration-test-messaging-jms + test-jar + test + + + + + + native + + + native + + + + native + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + integration-test + verify + + + + + + + + + virtualDependencies + + + !noVirtualDependencies + + + + + + org.apache.camel.quarkus + camel-quarkus-activemq-deployment + ${project.version} + pom + test + + + * + * + + + + + + + skip-testcontainers-tests + + + skip-testcontainers-tests + + + + true + + + + + diff --git a/integration-tests/activemq/src/main/java/org/apache/camel/quarkus/component/activemq/it/ActiveMQConnectionFactoryProducer.java b/integration-tests/activemq/src/main/java/org/apache/camel/quarkus/component/activemq/it/ActiveMQConnectionFactoryProducer.java new file mode 100644 index 000000000000..fcf89e3e441a --- /dev/null +++ b/integration-tests/activemq/src/main/java/org/apache/camel/quarkus/component/activemq/it/ActiveMQConnectionFactoryProducer.java @@ -0,0 +1,47 @@ +/* + * 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.activemq.it; + +import java.util.Arrays; +import java.util.Collections; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Singleton; +import jakarta.jms.ConnectionFactory; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.camel.quarkus.component.messaging.it.Person; +import org.apache.camel.support.DefaultExchangeHolder; +import org.eclipse.microprofile.config.inject.ConfigProperty; + +@ApplicationScoped +public class ActiveMQConnectionFactoryProducer { + + @ConfigProperty(name = "camel.component.activemq.broker-url") + String brokerUrl; + + @Singleton + @jakarta.enterprise.inject.Produces + public ConnectionFactory connectionFactory() { + ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerUrl); + factory.setTrustedPackages(Arrays.asList( + Collections.class.getPackageName(), + DefaultExchangeHolder.class.getPackageName(), + IllegalStateException.class.getPackageName(), + Person.class.getPackageName())); + return factory; + } +} diff --git a/integration-tests/activemq/src/test/java/org/apache/camel/quarkus/component/activemq/it/ActiveMQIT.java b/integration-tests/activemq/src/test/java/org/apache/camel/quarkus/component/activemq/it/ActiveMQIT.java new file mode 100644 index 000000000000..8d01eb016012 --- /dev/null +++ b/integration-tests/activemq/src/test/java/org/apache/camel/quarkus/component/activemq/it/ActiveMQIT.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.activemq.it; + +import io.quarkus.test.junit.QuarkusIntegrationTest; + +@QuarkusIntegrationTest +class ActiveMQIT extends ActiveMQTest { + +} diff --git a/integration-tests/activemq/src/test/java/org/apache/camel/quarkus/component/activemq/it/ActiveMQTest.java b/integration-tests/activemq/src/test/java/org/apache/camel/quarkus/component/activemq/it/ActiveMQTest.java new file mode 100644 index 000000000000..f084f912fa46 --- /dev/null +++ b/integration-tests/activemq/src/test/java/org/apache/camel/quarkus/component/activemq/it/ActiveMQTest.java @@ -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. + */ +package org.apache.camel.quarkus.component.activemq.it; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import org.apache.camel.quarkus.messaging.jms.AbstractJmsMessagingTest; + +@QuarkusTest +@QuarkusTestResource(ActiveMQTestResource.class) +class ActiveMQTest extends AbstractJmsMessagingTest { + +} diff --git a/integration-tests/activemq/src/test/java/org/apache/camel/quarkus/component/activemq/it/ActiveMQTestResource.java b/integration-tests/activemq/src/test/java/org/apache/camel/quarkus/component/activemq/it/ActiveMQTestResource.java new file mode 100644 index 000000000000..1191898bfa9c --- /dev/null +++ b/integration-tests/activemq/src/test/java/org/apache/camel/quarkus/component/activemq/it/ActiveMQTestResource.java @@ -0,0 +1,74 @@ +/* + * 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.activemq.it; + +import java.util.Collections; +import java.util.Map; + +import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.output.Slf4jLogConsumer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.utility.TestcontainersConfiguration; + +public class ActiveMQTestResource implements QuarkusTestResourceLifecycleManager { + private static final Logger LOGGER = LoggerFactory.getLogger(ActiveMQTestResource.class); + + private static final String ACTIVEMQ_IMAGE = "rmohr/activemq:5.15.9-alpine"; + private static final int TCP_PORT = 61616; + + private GenericContainer container; + + @Override + public Map start() { + LOGGER.info(TestcontainersConfiguration.getInstance().toString()); + + try { + container = new GenericContainer<>(ACTIVEMQ_IMAGE) + .withExposedPorts(TCP_PORT) + .withLogConsumer(new Slf4jLogConsumer(LOGGER)) + .waitingFor(Wait.forLogMessage(".*ActiveMQ.*started.*", 1)); + + container.start(); + + return Collections.singletonMap( + "camel.component.activemq.broker-url", + String.format( + "tcp://%s:%d?connectionTimeout=5000&tcpNoDelay=false&socket.OOBInline=false" + + "&jms.checkForDuplicates=false&jms.redeliveryPolicy.redeliveryDelay=1000" + + "&jms.prefetchPolicy.queuePrefetch=1000&jms.blobTransferPolicy.bufferSize=102400", + container.getHost(), + container.getMappedPort(TCP_PORT))); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public void stop() { + try { + if (container != null) { + container.stop(); + } + } catch (Exception e) { + // ignored + } + } +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 0e9584ac0c78..c95f6dfd4f74 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -54,6 +54,7 @@ main-yaml + activemq amqp arangodb diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index ec248f7d93e7..a388edfd2fc5 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -102,6 +102,11 @@ + + org.apache.camel + camel-activemq + ${camel.version} + org.apache.camel camel-amqp @@ -2685,6 +2690,16 @@ + + org.apache.camel.quarkus + camel-quarkus-activemq + ${camel-quarkus.version} + + + org.apache.camel.quarkus + camel-quarkus-activemq-deployment + ${camel-quarkus.version} + org.apache.camel.quarkus camel-quarkus-amqp diff --git a/poms/bom/src/main/generated/flattened-full-pom.xml b/poms/bom/src/main/generated/flattened-full-pom.xml index 6a43b48abdd3..0782356ec644 100644 --- a/poms/bom/src/main/generated/flattened-full-pom.xml +++ b/poms/bom/src/main/generated/flattened-full-pom.xml @@ -50,6 +50,11 @@ + + org.apache.camel + camel-activemq + 4.0.0-RC1 + org.apache.camel camel-amqp @@ -2621,6 +2626,16 @@ + + org.apache.camel.quarkus + camel-quarkus-activemq + 3.0.0-SNAPSHOT + + + org.apache.camel.quarkus + camel-quarkus-activemq-deployment + 3.0.0-SNAPSHOT + org.apache.camel.quarkus camel-quarkus-amqp diff --git a/poms/bom/src/main/generated/flattened-reduced-pom.xml b/poms/bom/src/main/generated/flattened-reduced-pom.xml index d284c58500c1..0c756064b729 100644 --- a/poms/bom/src/main/generated/flattened-reduced-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-pom.xml @@ -50,6 +50,11 @@ + + org.apache.camel + camel-activemq + 4.0.0-RC1 + org.apache.camel camel-amqp @@ -2621,6 +2626,16 @@ + + org.apache.camel.quarkus + camel-quarkus-activemq + 3.0.0-SNAPSHOT + + + org.apache.camel.quarkus + camel-quarkus-activemq-deployment + 3.0.0-SNAPSHOT + org.apache.camel.quarkus camel-quarkus-amqp diff --git a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml index 2fc24905ce08..e48a9b661a64 100644 --- a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml @@ -50,6 +50,11 @@ + + org.apache.camel + camel-activemq + 4.0.0-RC1 + org.apache.camel camel-amqp @@ -2621,6 +2626,16 @@ + + org.apache.camel.quarkus + camel-quarkus-activemq + 3.0.0-SNAPSHOT + + + org.apache.camel.quarkus + camel-quarkus-activemq-deployment + 3.0.0-SNAPSHOT + org.apache.camel.quarkus camel-quarkus-amqp diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml index cfb11e2bb2f5..ce65adffbbbf 100644 --- a/tooling/scripts/test-categories.yaml +++ b/tooling/scripts/test-categories.yaml @@ -136,6 +136,7 @@ group-08: - vertx - zendesk group-09: + - activemq - amqp - debug - ftp