This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch amq6 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 7d8a7e4ee0b22bb91f3c7590f414fe5428a4dac3 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sat May 18 11:50:01 2024 +0200 CAMEL-20600: camel-activemq6 for using 6.x brokers --- bom/camel-bom/pom.xml | 5 + catalog/camel-allcomponents/pom.xml | 5 + .../org/apache/camel/catalog/components.properties | 1 + .../apache/camel/catalog/components/activemq.json | 4 +- .../apache/camel/catalog/components/activemq6.json | 18 +- components/camel-activemq/pom.xml | 4 +- .../apache/camel/component/activemq/activemq.json | 4 +- .../services/org/apache/camel/component.properties | 4 +- .../src/main/docs/activemq-component.adoc | 12 +- .../camel/component/activemq/ActiveMQEndpoint.java | 4 +- .../{camel-activemq => camel-activemq6}/pom.xml | 10 +- .../activemq6/ActiveMQComponentConfigurer.java | 72 +++++ .../activemq6/ActiveMQEndpointConfigurer.java | 60 ++++ .../activemq6/ActiveMQEndpointUriFactory.java | 177 ++++++++++++ .../converter/ActiveMQConverterLoader.java | 63 +++++ .../converter/ActiveMQMessageConverterLoader.java | 65 +++++ .../camel/component/activemq6/activemq6.json} | 18 +- .../services/org/apache/camel/TypeConverterLoader | 3 + .../services/org/apache/camel/component.properties | 7 + .../services/org/apache/camel/component/activemq6 | 2 + .../apache/camel/configurer/activemq6-component | 2 + .../org/apache/camel/configurer/activemq6-endpoint | 2 + .../org/apache/camel/send-dynamic/activemq6 | 2 + .../org/apache/camel/urifactory/activemq6-endpoint | 2 + .../src/main/docs/activemq6-component.adoc} | 22 +- .../component/activemq6/ActiveMQComponent.java | 307 +++++++++++++++++++++ .../component/activemq6/ActiveMQConfiguration.java | 233 ++++++++++++++++ .../component/activemq6}/ActiveMQEndpoint.java | 8 +- .../component/activemq6/ActiveMQQueueEndpoint.java | 101 +++++++ .../activemq6/ActiveMQSendDynamicAware.java | 25 ++ .../activemq6/ActiveMQTemporaryQueueEndpoint.java | 39 +++ .../activemq6/ActiveMQTemporaryTopicEndpoint.java | 33 +++ .../OriginalDestinationPropagateStrategy.java | 55 ++++ .../activemq6/converter/ActiveMQConverter.java | 38 +++ .../converter/ActiveMQMessageConverter.java | 97 +++++++ .../component/activemq6/converter/package.html | 30 ++ .../component/activemq6/ActiveMQITSupport.java | 64 +++++ .../camel/component/activemq6/ActiveMQRouteIT.java | 120 ++++++++ .../camel/component/activemq6/ActiveMQToDIT.java | 68 +++++ .../activemq6/ActiveMQToDSendDynamicIT.java | 70 +++++ .../src/test/resources/log4j2-test.properties | 28 ++ components/pom.xml | 1 + .../org/apache/camel/main/components.properties | 1 + .../modules/ROOT/examples/json/activemq6.json | 1 + docs/components/modules/ROOT/nav.adoc | 3 +- .../modules/ROOT/pages/activemq6-component.adoc | 1 + .../component/ComponentsBuilderFactory.java | 4 +- .../dsl/ActivemqComponentBuilderFactory.java | 10 +- .../builder/endpoint/StaticEndpointBuilders.java | 62 ++++- .../dsl/ActiveMQEndpointBuilderFactory.java | 36 +-- .../camel-component-known-dependencies.properties | 1 + .../camel-main-known-dependencies.properties | 1 + .../{ActivemqUriDsl.kt => Activemq6UriDsl.kt} | 10 +- .../camel/kotlin/components/ActivemqUriDsl.kt | 2 +- parent/pom.xml | 6 + 55 files changed, 1939 insertions(+), 84 deletions(-) diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml index 1222027c0a9..e62328dcf25 100644 --- a/bom/camel-bom/pom.xml +++ b/bom/camel-bom/pom.xml @@ -51,6 +51,11 @@ <artifactId>camel-activemq</artifactId> <version>4.7.0-SNAPSHOT</version> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-activemq6</artifactId> + <version>4.7.0-SNAPSHOT</version> + </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-amqp</artifactId> diff --git a/catalog/camel-allcomponents/pom.xml b/catalog/camel-allcomponents/pom.xml index 1ad3d5e95c2..2dfc5615942 100644 --- a/catalog/camel-allcomponents/pom.xml +++ b/catalog/camel-allcomponents/pom.xml @@ -52,6 +52,11 @@ <artifactId>camel-activemq</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-activemq6</artifactId> + <version>${project.version}</version> + </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-amqp</artifactId> diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components.properties b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components.properties index 73dcf99cd95..eda05e1c4c1 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components.properties +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components.properties @@ -1,4 +1,5 @@ activemq +activemq6 amqp arangodb as2 diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/activemq.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/activemq.json index b4ed7dedf93..2b7976dc274 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/activemq.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/activemq.json @@ -2,8 +2,8 @@ "component": { "kind": "component", "name": "activemq", - "title": "ActiveMQ", - "description": "Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS component.", + "title": "ActiveMQ 5.x", + "description": "Send messages to (or consume from) Apache ActiveMQ 5.x. This component extends the Camel JMS component.", "deprecated": false, "firstVersion": "1.0.0", "label": "messaging", diff --git a/components/camel-activemq/src/generated/resources/META-INF/org/apache/camel/component/activemq/activemq.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/activemq6.json similarity index 99% copy from components/camel-activemq/src/generated/resources/META-INF/org/apache/camel/component/activemq/activemq.json copy to catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/activemq6.json index b4ed7dedf93..aa2fbe8e465 100644 --- a/components/camel-activemq/src/generated/resources/META-INF/org/apache/camel/component/activemq/activemq.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/activemq6.json @@ -1,20 +1,20 @@ { "component": { "kind": "component", - "name": "activemq", - "title": "ActiveMQ", - "description": "Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS component.", + "name": "activemq6", + "title": "ActiveMQ 6.x", + "description": "Send messages to (or consume from) Apache ActiveMQ 6.x. This component extends the Camel JMS component.", "deprecated": false, - "firstVersion": "1.0.0", + "firstVersion": "4.7.0", "label": "messaging", - "javaType": "org.apache.camel.component.activemq.ActiveMQComponent", - "supportLevel": "Stable", + "javaType": "org.apache.camel.component.activemq6.ActiveMQComponent", + "supportLevel": "Preview", "groupId": "org.apache.camel", - "artifactId": "camel-activemq", + "artifactId": "camel-activemq6", "version": "4.7.0-SNAPSHOT", - "scheme": "activemq", + "scheme": "activemq6", "extendsScheme": "jms", - "syntax": "activemq:destinationType:destinationName", + "syntax": "activemq6:destinationType:destinationName", "async": true, "api": false, "consumerOnly": false, diff --git a/components/camel-activemq/pom.xml b/components/camel-activemq/pom.xml index aaad6395eff..1fd2bf83631 100644 --- a/components/camel-activemq/pom.xml +++ b/components/camel-activemq/pom.xml @@ -30,8 +30,8 @@ <artifactId>camel-activemq</artifactId> <packaging>jar</packaging> - <name>Camel :: ActiveMQ</name> - <description>ActiveMQ component for Camel</description> + <name>Camel :: ActiveMQ 5.x</name> + <description>ActiveMQ 5.x component for Camel</description> <properties> <camel.surefire.parallel>true</camel.surefire.parallel> diff --git a/components/camel-activemq/src/generated/resources/META-INF/org/apache/camel/component/activemq/activemq.json b/components/camel-activemq/src/generated/resources/META-INF/org/apache/camel/component/activemq/activemq.json index b4ed7dedf93..2b7976dc274 100644 --- a/components/camel-activemq/src/generated/resources/META-INF/org/apache/camel/component/activemq/activemq.json +++ b/components/camel-activemq/src/generated/resources/META-INF/org/apache/camel/component/activemq/activemq.json @@ -2,8 +2,8 @@ "component": { "kind": "component", "name": "activemq", - "title": "ActiveMQ", - "description": "Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS component.", + "title": "ActiveMQ 5.x", + "description": "Send messages to (or consume from) Apache ActiveMQ 5.x. This component extends the Camel JMS component.", "deprecated": false, "firstVersion": "1.0.0", "label": "messaging", diff --git a/components/camel-activemq/src/generated/resources/META-INF/services/org/apache/camel/component.properties b/components/camel-activemq/src/generated/resources/META-INF/services/org/apache/camel/component.properties index f079d293639..cd2173636d1 100644 --- a/components/camel-activemq/src/generated/resources/META-INF/services/org/apache/camel/component.properties +++ b/components/camel-activemq/src/generated/resources/META-INF/services/org/apache/camel/component.properties @@ -3,5 +3,5 @@ components=activemq groupId=org.apache.camel artifactId=camel-activemq version=4.7.0-SNAPSHOT -projectName=Camel :: ActiveMQ -projectDescription=ActiveMQ component for Camel +projectName=Camel :: ActiveMQ 5.x +projectDescription=ActiveMQ 5.x component for Camel diff --git a/components/camel-activemq/src/main/docs/activemq-component.adoc b/components/camel-activemq/src/main/docs/activemq-component.adoc index 59c379801ae..239e95659f9 100644 --- a/components/camel-activemq/src/main/docs/activemq-component.adoc +++ b/components/camel-activemq/src/main/docs/activemq-component.adoc @@ -1,8 +1,8 @@ -= ActiveMQ Component -:doctitle: ActiveMQ += ActiveMQ 5.x Component +:doctitle: ActiveMQ 5.x :shortname: activemq :artifactid: camel-activemq -:description: Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS component. +:description: Send messages to (or consume from) Apache ActiveMQ 5.x. This component extends the Camel JMS component. :since: 1.0 :supportlevel: Stable :tabs-sync-option: @@ -17,6 +17,12 @@ The ActiveMQ component is an extension to the JMS component and has been pre-configured for using Apache ActiveMQ 5.x (not Artemis). Users of Apache ActiveMQ Artemis should use the JMS component. +[IMPORTANT] +==== +The camel-activemq component is best intended for ActiveMQ 5.x classic brokers. If you use ActiveMQ 6.x brokers, +then use the camel-activemq6 component instead. +==== + [TIP] ==== *More documentation* diff --git a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQEndpoint.java b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQEndpoint.java index 1ba72b7fd65..bea3f0be8a7 100644 --- a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQEndpoint.java +++ b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQEndpoint.java @@ -27,9 +27,9 @@ import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; /** - * Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS component. + * Send messages to (or consume from) Apache ActiveMQ 5.x. This component extends the Camel JMS component. */ -@UriEndpoint(firstVersion = "1.0.0", extendsScheme = "jms", scheme = "activemq", title = "ActiveMQ", +@UriEndpoint(firstVersion = "1.0.0", extendsScheme = "jms", scheme = "activemq", title = "ActiveMQ 5.x", syntax = "activemq:destinationType:destinationName", category = { Category.MESSAGING }) public class ActiveMQEndpoint extends JmsEndpoint { diff --git a/components/camel-activemq/pom.xml b/components/camel-activemq6/pom.xml similarity index 91% copy from components/camel-activemq/pom.xml copy to components/camel-activemq6/pom.xml index aaad6395eff..f8f93a74681 100644 --- a/components/camel-activemq/pom.xml +++ b/components/camel-activemq6/pom.xml @@ -27,11 +27,11 @@ <version>4.7.0-SNAPSHOT</version> </parent> - <artifactId>camel-activemq</artifactId> + <artifactId>camel-activemq6</artifactId> <packaging>jar</packaging> - <name>Camel :: ActiveMQ</name> - <description>ActiveMQ component for Camel</description> + <name>Camel :: ActiveMQ 6.x</name> + <description>ActiveMQ 6.x component for Camel</description> <properties> <camel.surefire.parallel>true</camel.surefire.parallel> @@ -48,8 +48,8 @@ </dependency> <dependency> <groupId>org.apache.activemq</groupId> - <artifactId>activemq-client-jakarta</artifactId> - <version>${activemq-version}</version> + <artifactId>activemq-client</artifactId> + <version>${activemq6-version}</version> </dependency> <dependency> diff --git a/components/camel-activemq6/src/generated/java/org/apache/camel/component/activemq6/ActiveMQComponentConfigurer.java b/components/camel-activemq6/src/generated/java/org/apache/camel/component/activemq6/ActiveMQComponentConfigurer.java new file mode 100644 index 00000000000..2b19c0a799c --- /dev/null +++ b/components/camel-activemq6/src/generated/java/org/apache/camel/component/activemq6/ActiveMQComponentConfigurer.java @@ -0,0 +1,72 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.activemq6; + +import javax.annotation.processing.Generated; +import java.util.Map; + +import org.apache.camel.CamelContext; +import org.apache.camel.spi.ExtendedPropertyConfigurerGetter; +import org.apache.camel.spi.PropertyConfigurerGetter; +import org.apache.camel.spi.ConfigurerStrategy; +import org.apache.camel.spi.GeneratedPropertyConfigurer; +import org.apache.camel.util.CaseInsensitiveMap; +import org.apache.camel.component.jms.JmsComponentConfigurer; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.EndpointSchemaGeneratorMojo") +@SuppressWarnings("unchecked") +public class ActiveMQComponentConfigurer extends JmsComponentConfigurer implements GeneratedPropertyConfigurer, PropertyConfigurerGetter { + + @Override + public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { + ActiveMQComponent target = (ActiveMQComponent) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "brokerurl": + case "brokerURL": target.setBrokerURL(property(camelContext, java.lang.String.class, value)); return true; + case "embedded": target.setEmbedded(property(camelContext, boolean.class, value)); return true; + case "trustallpackages": + case "trustAllPackages": target.setTrustAllPackages(property(camelContext, boolean.class, value)); return true; + case "usepooledconnection": + case "usePooledConnection": target.setUsePooledConnection(property(camelContext, boolean.class, value)); return true; + case "usesingleconnection": + case "useSingleConnection": target.setUseSingleConnection(property(camelContext, boolean.class, value)); return true; + default: return super.configure(camelContext, obj, name, value, ignoreCase); + } + } + + @Override + public Class<?> getOptionType(String name, boolean ignoreCase) { + switch (ignoreCase ? name.toLowerCase() : name) { + case "brokerurl": + case "brokerURL": return java.lang.String.class; + case "embedded": return boolean.class; + case "trustallpackages": + case "trustAllPackages": return boolean.class; + case "usepooledconnection": + case "usePooledConnection": return boolean.class; + case "usesingleconnection": + case "useSingleConnection": return boolean.class; + default: return super.getOptionType(name, ignoreCase); + } + } + + @Override + public Object getOptionValue(Object obj, String name, boolean ignoreCase) { + ActiveMQComponent target = (ActiveMQComponent) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "brokerurl": + case "brokerURL": return target.getBrokerURL(); + case "embedded": return target.isEmbedded(); + case "trustallpackages": + case "trustAllPackages": return target.isTrustAllPackages(); + case "usepooledconnection": + case "usePooledConnection": return target.isUsePooledConnection(); + case "usesingleconnection": + case "useSingleConnection": return target.isUseSingleConnection(); + default: return super.getOptionValue(obj, name, ignoreCase); + } + } +} + diff --git a/components/camel-activemq6/src/generated/java/org/apache/camel/component/activemq6/ActiveMQEndpointConfigurer.java b/components/camel-activemq6/src/generated/java/org/apache/camel/component/activemq6/ActiveMQEndpointConfigurer.java new file mode 100644 index 00000000000..73cde51a0a1 --- /dev/null +++ b/components/camel-activemq6/src/generated/java/org/apache/camel/component/activemq6/ActiveMQEndpointConfigurer.java @@ -0,0 +1,60 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.activemq6; + +import javax.annotation.processing.Generated; +import java.util.Map; + +import org.apache.camel.CamelContext; +import org.apache.camel.spi.ExtendedPropertyConfigurerGetter; +import org.apache.camel.spi.PropertyConfigurerGetter; +import org.apache.camel.spi.ConfigurerStrategy; +import org.apache.camel.spi.GeneratedPropertyConfigurer; +import org.apache.camel.util.CaseInsensitiveMap; +import org.apache.camel.component.jms.JmsEndpointConfigurer; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.EndpointSchemaGeneratorMojo") +@SuppressWarnings("unchecked") +public class ActiveMQEndpointConfigurer extends JmsEndpointConfigurer implements GeneratedPropertyConfigurer, PropertyConfigurerGetter { + + @Override + public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { + ActiveMQEndpoint target = (ActiveMQEndpoint) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "destinationoptions": + case "destinationOptions": target.setDestinationOptions(property(camelContext, java.util.Map.class, value)); return true; + default: return super.configure(camelContext, obj, name, value, ignoreCase); + } + } + + @Override + public Class<?> getOptionType(String name, boolean ignoreCase) { + switch (ignoreCase ? name.toLowerCase() : name) { + case "destinationoptions": + case "destinationOptions": return java.util.Map.class; + default: return super.getOptionType(name, ignoreCase); + } + } + + @Override + public Object getOptionValue(Object obj, String name, boolean ignoreCase) { + ActiveMQEndpoint target = (ActiveMQEndpoint) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "destinationoptions": + case "destinationOptions": return target.getDestinationOptions(); + default: return super.getOptionValue(obj, name, ignoreCase); + } + } + + @Override + public Object getCollectionValueType(Object target, String name, boolean ignoreCase) { + switch (ignoreCase ? name.toLowerCase() : name) { + case "destinationoptions": + case "destinationOptions": return java.lang.String.class; + default: return super.getCollectionValueType(target, name, ignoreCase); + } + } +} + diff --git a/components/camel-activemq6/src/generated/java/org/apache/camel/component/activemq6/ActiveMQEndpointUriFactory.java b/components/camel-activemq6/src/generated/java/org/apache/camel/component/activemq6/ActiveMQEndpointUriFactory.java new file mode 100644 index 00000000000..e24936c4720 --- /dev/null +++ b/components/camel-activemq6/src/generated/java/org/apache/camel/component/activemq6/ActiveMQEndpointUriFactory.java @@ -0,0 +1,177 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.activemq6; + +import javax.annotation.processing.Generated; +import java.net.URISyntaxException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.camel.spi.EndpointUriFactory; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.GenerateEndpointUriFactoryMojo") +public class ActiveMQEndpointUriFactory extends org.apache.camel.support.component.EndpointUriFactorySupport implements EndpointUriFactory { + + private static final String BASE = ":destinationType:destinationName"; + + private static final Set<String> PROPERTY_NAMES; + private static final Set<String> SECRET_PROPERTY_NAMES; + private static final Set<String> MULTI_VALUE_PREFIXES; + static { + Set<String> props = new HashSet<>(102); + props.add("acceptMessagesWhileStopping"); + props.add("acknowledgementModeName"); + props.add("allowAdditionalHeaders"); + props.add("allowNullBody"); + props.add("allowReplyManagerQuickStop"); + props.add("allowSerializedHeaders"); + props.add("alwaysCopyMessage"); + props.add("artemisConsumerPriority"); + props.add("artemisStreamingEnabled"); + props.add("asyncConsumer"); + props.add("asyncStartListener"); + props.add("asyncStopListener"); + props.add("autoStartup"); + props.add("cacheLevel"); + props.add("cacheLevelName"); + props.add("clientId"); + props.add("concurrentConsumers"); + props.add("connectionFactory"); + props.add("consumerType"); + props.add("correlationProperty"); + props.add("defaultTaskExecutorType"); + props.add("deliveryDelay"); + props.add("deliveryMode"); + props.add("deliveryPersistent"); + props.add("destinationName"); + props.add("destinationOptions"); + props.add("destinationResolver"); + props.add("destinationType"); + props.add("disableReplyTo"); + props.add("disableTimeToLive"); + props.add("durableSubscriptionName"); + props.add("eagerLoadingOfProperties"); + props.add("eagerPoisonBody"); + props.add("errorHandler"); + props.add("errorHandlerLogStackTrace"); + props.add("errorHandlerLoggingLevel"); + props.add("exceptionHandler"); + props.add("exceptionListener"); + props.add("exchangePattern"); + props.add("explicitQosEnabled"); + props.add("exposeListenerSession"); + props.add("forceSendOriginalMessage"); + props.add("formatDateHeadersToIso8601"); + props.add("headerFilterStrategy"); + props.add("idleConsumerLimit"); + props.add("idleTaskExecutionLimit"); + props.add("includeAllJMSXProperties"); + props.add("includeSentJMSMessageID"); + props.add("jmsKeyFormatStrategy"); + props.add("jmsMessageType"); + props.add("lazyCreateTransactionManager"); + props.add("lazyStartProducer"); + props.add("mapJmsMessage"); + props.add("maxConcurrentConsumers"); + props.add("maxMessagesPerTask"); + props.add("messageConverter"); + props.add("messageCreatedStrategy"); + props.add("messageIdEnabled"); + props.add("messageListenerContainerFactory"); + props.add("messageTimestampEnabled"); + props.add("password"); + props.add("preserveMessageQos"); + props.add("priority"); + props.add("pubSubNoLocal"); + props.add("receiveTimeout"); + props.add("recoveryInterval"); + props.add("replyTo"); + props.add("replyToCacheLevelName"); + props.add("replyToConcurrentConsumers"); + props.add("replyToConsumerType"); + props.add("replyToDeliveryPersistent"); + props.add("replyToDestinationSelectorName"); + props.add("replyToMaxConcurrentConsumers"); + props.add("replyToOnTimeoutMaxConcurrentConsumers"); + props.add("replyToOverride"); + props.add("replyToSameDestinationAllowed"); + props.add("replyToType"); + props.add("requestTimeout"); + props.add("requestTimeoutCheckerInterval"); + props.add("selector"); + props.add("streamMessageTypeEnabled"); + props.add("subscriptionDurable"); + props.add("subscriptionName"); + props.add("subscriptionShared"); + props.add("synchronous"); + props.add("taskExecutor"); + props.add("temporaryQueueResolver"); + props.add("testConnectionOnStartup"); + props.add("timeToLive"); + props.add("transacted"); + props.add("transactedInOut"); + props.add("transactionManager"); + props.add("transactionName"); + props.add("transactionTimeout"); + props.add("transferException"); + props.add("transferExchange"); + props.add("useMessageIDAsCorrelationID"); + props.add("username"); + props.add("waitForProvisionCorrelationToBeUpdatedCounter"); + props.add("waitForProvisionCorrelationToBeUpdatedThreadSleepingTime"); + props.add("waitForTemporaryReplyToToBeUpdatedCounter"); + props.add("waitForTemporaryReplyToToBeUpdatedThreadSleepingTime"); + PROPERTY_NAMES = Collections.unmodifiableSet(props); + Set<String> secretProps = new HashSet<>(2); + secretProps.add("password"); + secretProps.add("username"); + SECRET_PROPERTY_NAMES = Collections.unmodifiableSet(secretProps); + Set<String> prefixes = new HashSet<>(1); + prefixes.add("destination."); + MULTI_VALUE_PREFIXES = Collections.unmodifiableSet(prefixes); + } + + @Override + public boolean isEnabled(String scheme) { + return "activemq6".equals(scheme); + } + + @Override + public String buildUri(String scheme, Map<String, Object> properties, boolean encode) throws URISyntaxException { + String syntax = scheme + BASE; + String uri = syntax; + + Map<String, Object> copy = new HashMap<>(properties); + + uri = buildPathParameter(syntax, uri, "destinationType", "queue", false, copy); + uri = buildPathParameter(syntax, uri, "destinationName", null, true, copy); + uri = buildQueryParameters(uri, copy, encode); + return uri; + } + + @Override + public Set<String> propertyNames() { + return PROPERTY_NAMES; + } + + @Override + public Set<String> secretPropertyNames() { + return SECRET_PROPERTY_NAMES; + } + + @Override + public Set<String> multiValuePrefixes() { + return MULTI_VALUE_PREFIXES; + } + + @Override + public boolean isLenientProperties() { + return false; + } +} + diff --git a/components/camel-activemq6/src/generated/java/org/apache/camel/component/activemq6/converter/ActiveMQConverterLoader.java b/components/camel-activemq6/src/generated/java/org/apache/camel/component/activemq6/converter/ActiveMQConverterLoader.java new file mode 100644 index 00000000000..9abed9947a4 --- /dev/null +++ b/components/camel-activemq6/src/generated/java/org/apache/camel/component/activemq6/converter/ActiveMQConverterLoader.java @@ -0,0 +1,63 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.activemq6.converter; + +import javax.annotation.processing.Generated; + +import org.apache.camel.CamelContext; +import org.apache.camel.CamelContextAware; +import org.apache.camel.DeferredContextBinding; +import org.apache.camel.Exchange; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverterLoaderException; +import org.apache.camel.spi.TypeConverterLoader; +import org.apache.camel.spi.TypeConverterRegistry; +import org.apache.camel.support.SimpleTypeConverter; +import org.apache.camel.support.TypeConverterSupport; +import org.apache.camel.util.DoubleMap; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.TypeConverterLoaderGeneratorMojo") +@SuppressWarnings("unchecked") +@DeferredContextBinding +public final class ActiveMQConverterLoader implements TypeConverterLoader, CamelContextAware { + + private CamelContext camelContext; + + public ActiveMQConverterLoader() { + } + + @Override + public void setCamelContext(CamelContext camelContext) { + this.camelContext = camelContext; + } + + @Override + public CamelContext getCamelContext() { + return camelContext; + } + + @Override + public void load(TypeConverterRegistry registry) throws TypeConverterLoaderException { + registerConverters(registry); + } + + private void registerConverters(TypeConverterRegistry registry) { + addTypeConverter(registry, org.apache.activemq.command.ActiveMQDestination.class, java.lang.String.class, false, + (type, exchange, value) -> getActiveMQConverter().toDestination((java.lang.String) value)); + } + + private static void addTypeConverter(TypeConverterRegistry registry, Class<?> toType, Class<?> fromType, boolean allowNull, SimpleTypeConverter.ConversionMethod method) { + registry.addTypeConverter(toType, fromType, new SimpleTypeConverter(allowNull, method)); + } + + private volatile org.apache.camel.component.activemq6.converter.ActiveMQConverter activeMQConverter; + private org.apache.camel.component.activemq6.converter.ActiveMQConverter getActiveMQConverter() { + if (activeMQConverter == null) { + activeMQConverter = new org.apache.camel.component.activemq6.converter.ActiveMQConverter(); + CamelContextAware.trySetCamelContext(activeMQConverter, camelContext); + } + return activeMQConverter; + } +} diff --git a/components/camel-activemq6/src/generated/java/org/apache/camel/component/activemq6/converter/ActiveMQMessageConverterLoader.java b/components/camel-activemq6/src/generated/java/org/apache/camel/component/activemq6/converter/ActiveMQMessageConverterLoader.java new file mode 100644 index 00000000000..8abad95a23c --- /dev/null +++ b/components/camel-activemq6/src/generated/java/org/apache/camel/component/activemq6/converter/ActiveMQMessageConverterLoader.java @@ -0,0 +1,65 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.activemq6.converter; + +import javax.annotation.processing.Generated; + +import org.apache.camel.CamelContext; +import org.apache.camel.CamelContextAware; +import org.apache.camel.DeferredContextBinding; +import org.apache.camel.Exchange; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverterLoaderException; +import org.apache.camel.spi.TypeConverterLoader; +import org.apache.camel.spi.TypeConverterRegistry; +import org.apache.camel.support.SimpleTypeConverter; +import org.apache.camel.support.TypeConverterSupport; +import org.apache.camel.util.DoubleMap; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.TypeConverterLoaderGeneratorMojo") +@SuppressWarnings("unchecked") +@DeferredContextBinding +public final class ActiveMQMessageConverterLoader implements TypeConverterLoader, CamelContextAware { + + private CamelContext camelContext; + + public ActiveMQMessageConverterLoader() { + } + + @Override + public void setCamelContext(CamelContext camelContext) { + this.camelContext = camelContext; + } + + @Override + public CamelContext getCamelContext() { + return camelContext; + } + + @Override + public void load(TypeConverterRegistry registry) throws TypeConverterLoaderException { + registerConverters(registry); + } + + private void registerConverters(TypeConverterRegistry registry) { + addTypeConverter(registry, org.apache.activemq.command.ActiveMQMessage.class, org.apache.camel.Exchange.class, false, + (type, exchange, value) -> getActiveMQMessageConverter().toMessage((org.apache.camel.Exchange) value)); + addTypeConverter(registry, org.apache.camel.Processor.class, jakarta.jms.MessageListener.class, false, + (type, exchange, value) -> getActiveMQMessageConverter().toProcessor((jakarta.jms.MessageListener) value)); + } + + private static void addTypeConverter(TypeConverterRegistry registry, Class<?> toType, Class<?> fromType, boolean allowNull, SimpleTypeConverter.ConversionMethod method) { + registry.addTypeConverter(toType, fromType, new SimpleTypeConverter(allowNull, method)); + } + + private volatile org.apache.camel.component.activemq6.converter.ActiveMQMessageConverter activeMQMessageConverter; + private org.apache.camel.component.activemq6.converter.ActiveMQMessageConverter getActiveMQMessageConverter() { + if (activeMQMessageConverter == null) { + activeMQMessageConverter = new org.apache.camel.component.activemq6.converter.ActiveMQMessageConverter(); + CamelContextAware.trySetCamelContext(activeMQMessageConverter, camelContext); + } + return activeMQMessageConverter; + } +} diff --git a/components/camel-activemq/src/generated/resources/META-INF/org/apache/camel/component/activemq/activemq.json b/components/camel-activemq6/src/generated/resources/META-INF/org/apache/camel/component/activemq6/activemq6.json similarity index 99% copy from components/camel-activemq/src/generated/resources/META-INF/org/apache/camel/component/activemq/activemq.json copy to components/camel-activemq6/src/generated/resources/META-INF/org/apache/camel/component/activemq6/activemq6.json index b4ed7dedf93..aa2fbe8e465 100644 --- a/components/camel-activemq/src/generated/resources/META-INF/org/apache/camel/component/activemq/activemq.json +++ b/components/camel-activemq6/src/generated/resources/META-INF/org/apache/camel/component/activemq6/activemq6.json @@ -1,20 +1,20 @@ { "component": { "kind": "component", - "name": "activemq", - "title": "ActiveMQ", - "description": "Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS component.", + "name": "activemq6", + "title": "ActiveMQ 6.x", + "description": "Send messages to (or consume from) Apache ActiveMQ 6.x. This component extends the Camel JMS component.", "deprecated": false, - "firstVersion": "1.0.0", + "firstVersion": "4.7.0", "label": "messaging", - "javaType": "org.apache.camel.component.activemq.ActiveMQComponent", - "supportLevel": "Stable", + "javaType": "org.apache.camel.component.activemq6.ActiveMQComponent", + "supportLevel": "Preview", "groupId": "org.apache.camel", - "artifactId": "camel-activemq", + "artifactId": "camel-activemq6", "version": "4.7.0-SNAPSHOT", - "scheme": "activemq", + "scheme": "activemq6", "extendsScheme": "jms", - "syntax": "activemq:destinationType:destinationName", + "syntax": "activemq6:destinationType:destinationName", "async": true, "api": false, "consumerOnly": false, diff --git a/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader b/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader new file mode 100644 index 00000000000..046215684dc --- /dev/null +++ b/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader @@ -0,0 +1,3 @@ +# Generated by camel build tools - do NOT edit this file! +org.apache.camel.component.activemq6.converter.ActiveMQConverterLoader +org.apache.camel.component.activemq6.converter.ActiveMQMessageConverterLoader diff --git a/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/component.properties b/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/component.properties new file mode 100644 index 00000000000..af91f61c4f4 --- /dev/null +++ b/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/component.properties @@ -0,0 +1,7 @@ +# Generated by camel build tools - do NOT edit this file! +components=activemq6 +groupId=org.apache.camel +artifactId=camel-activemq6 +version=4.7.0-SNAPSHOT +projectName=Camel :: ActiveMQ 6.x +projectDescription=ActiveMQ 6.x component for Camel diff --git a/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/component/activemq6 b/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/component/activemq6 new file mode 100644 index 00000000000..15550bfb3b6 --- /dev/null +++ b/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/component/activemq6 @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.activemq6.ActiveMQComponent diff --git a/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/configurer/activemq6-component b/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/configurer/activemq6-component new file mode 100644 index 00000000000..85c4cc88f78 --- /dev/null +++ b/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/configurer/activemq6-component @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.activemq6.ActiveMQComponentConfigurer diff --git a/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/configurer/activemq6-endpoint b/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/configurer/activemq6-endpoint new file mode 100644 index 00000000000..70485adabb9 --- /dev/null +++ b/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/configurer/activemq6-endpoint @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.activemq6.ActiveMQEndpointConfigurer diff --git a/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/send-dynamic/activemq6 b/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/send-dynamic/activemq6 new file mode 100644 index 00000000000..6ca6f8d9c9b --- /dev/null +++ b/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/send-dynamic/activemq6 @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.activemq6.ActiveMQSendDynamicAware diff --git a/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/urifactory/activemq6-endpoint b/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/urifactory/activemq6-endpoint new file mode 100644 index 00000000000..bdf586b34f5 --- /dev/null +++ b/components/camel-activemq6/src/generated/resources/META-INF/services/org/apache/camel/urifactory/activemq6-endpoint @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.activemq6.ActiveMQEndpointUriFactory diff --git a/components/camel-activemq/src/main/docs/activemq-component.adoc b/components/camel-activemq6/src/main/docs/activemq6-component.adoc similarity index 84% copy from components/camel-activemq/src/main/docs/activemq-component.adoc copy to components/camel-activemq6/src/main/docs/activemq6-component.adoc index 59c379801ae..27f13d0e768 100644 --- a/components/camel-activemq/src/main/docs/activemq-component.adoc +++ b/components/camel-activemq6/src/main/docs/activemq6-component.adoc @@ -1,10 +1,10 @@ -= ActiveMQ Component -:doctitle: ActiveMQ -:shortname: activemq -:artifactid: camel-activemq -:description: Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS component. -:since: 1.0 -:supportlevel: Stable += ActiveMQ 6.x Component +:doctitle: ActiveMQ 6.x +:shortname: activemq6 +:artifactid: camel-activemq6 +:description: Send messages to (or consume from) Apache ActiveMQ 6.x. This component extends the Camel JMS component. +:since: 4.7 +:supportlevel: Preview :tabs-sync-option: :component-header: Both producer and consumer are supported //Manually maintained attributes @@ -14,9 +14,15 @@ *{component-header}* -The ActiveMQ component is an extension to the JMS component and has been pre-configured for using Apache ActiveMQ 5.x (not Artemis). +The ActiveMQ component is an extension to the JMS component and has been pre-configured for using Apache ActiveMQ 6.x (not Artemis). Users of Apache ActiveMQ Artemis should use the JMS component. +[IMPORTANT] +==== +The camel-activemq component is best intended for ActiveMQ 6.x brokers. If you use ActiveMQ 5.x brokers, +then use the camel-activemq 5.x component instead. +==== + [TIP] ==== *More documentation* diff --git a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQComponent.java b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQComponent.java new file mode 100644 index 00000000000..a3c263d25b2 --- /dev/null +++ b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQComponent.java @@ -0,0 +1,307 @@ +/* + * 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.component.activemq6; + +import java.lang.reflect.Method; +import java.util.Map; +import java.util.concurrent.CopyOnWriteArrayList; + +import org.apache.camel.CamelContext; +import org.apache.camel.Endpoint; +import org.apache.camel.component.jms.JmsComponent; +import org.apache.camel.component.jms.JmsConfiguration; +import org.apache.camel.component.jms.JmsEndpoint; +import org.apache.camel.component.jms.QueueBrowseStrategy; +import org.apache.camel.spi.Metadata; +import org.apache.camel.spi.annotations.Component; +import org.apache.camel.support.component.PropertyConfigurerSupport; +import org.apache.camel.util.ObjectHelper; +import org.apache.camel.util.PropertiesHelper; +import org.apache.camel.util.URISupport; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.jms.connection.SingleConnectionFactory; +import org.springframework.jms.core.JmsTemplate; + +/** + * The ActiveMQ 6.x Component. + */ +@Component("activemq6") +public class ActiveMQComponent extends JmsComponent { + + private static final Logger LOG = LoggerFactory.getLogger(ActiveMQComponent.class); + + private final CopyOnWriteArrayList<SingleConnectionFactory> singleConnectionFactoryList = new CopyOnWriteArrayList<>(); + private final CopyOnWriteArrayList<Object> pooledConnectionFactoryServiceList = new CopyOnWriteArrayList<>(); + private boolean embedded; + + public ActiveMQComponent() { + } + + public ActiveMQComponent(CamelContext context) { + super(context); + } + + public ActiveMQComponent(ActiveMQConfiguration configuration) { + setConfiguration(configuration); + } + + /** + * Creates an <a href="http://camel.apache.org/activemq.html">ActiveMQ Component</a> + * + * @return the created component + */ + public static ActiveMQComponent activeMQComponent() { + return new ActiveMQComponent(); + } + + /** + * Creates an <a href="http://camel.apache.org/activemq.html">ActiveMQ Component</a> connecting to the given + * <a href="http://activemq.apache.org/configuring-transports.html">broker URL</a> + * + * @param brokerURL the URL to connect to + * @return the created component + */ + public static ActiveMQComponent activeMQComponent(String brokerURL) { + ActiveMQComponent answer = new ActiveMQComponent(); + if (answer.getConfiguration() instanceof ActiveMQConfiguration) { + ((ActiveMQConfiguration) answer.getConfiguration()).setBrokerURL(brokerURL); + } + + return answer; + } + + public boolean isEmbedded() { + return embedded; + } + + /** + * Use an embedded in-memory (non-persistent) ActiveMQ broker for development and testing purposes. You must have + * activemq-broker JAR on the classpath. + */ + @Metadata(label = "common") + public void setEmbedded(boolean embedded) { + this.embedded = embedded; + if (embedded) { + setBrokerURL("vm://localhost?broker.persistent=false"); + LOG.info("Using embedded in-memory ActiveMQ broker (you must have activemq-broker JAR added as dependency)"); + } + } + + public String getBrokerURL() { + if (getConfiguration() instanceof ActiveMQConfiguration activeMQConfiguration) { + return activeMQConfiguration.getBrokerURL(); + } + return null; + } + + /** + * Sets the broker URL to use to connect to ActiveMQ. If none configured then localhost:61616 is used by default + * (however can be overridden by configuration from environment variables) + */ + @Metadata(label = "common") + public void setBrokerURL(String brokerURL) { + if (getConfiguration() instanceof ActiveMQConfiguration activeMQConfiguration) { + activeMQConfiguration.setBrokerURL(brokerURL); + } + } + + /** + * Define if all Java packages are trusted or not (for Java object JMS message types). Notice its not recommended + * practice to send Java serialized objects over network. Setting this to true can expose security risks, so use + * this with care. + */ + @Metadata(defaultValue = "false", label = "advanced") + public void setTrustAllPackages(boolean trustAllPackages) { + if (getConfiguration() instanceof ActiveMQConfiguration activeMQConfiguration) { + activeMQConfiguration.setTrustAllPackages(trustAllPackages); + } + } + + public boolean isTrustAllPackages() { + if (getConfiguration() instanceof ActiveMQConfiguration activeMQConfiguration) { + return activeMQConfiguration.isTrustAllPackages(); + } + return false; + } + + /** + * Enables or disables whether a PooledConnectionFactory will be used so that when messages are sent to ActiveMQ + * from outside a message consuming thread, pooling will be used rather than the default with the Spring + * {@link JmsTemplate} which will create a new connection, session, producer for each message then close them all + * down again. + * <p/> + * The default value is true. + */ + @Metadata(defaultValue = "true", label = "common") + public void setUsePooledConnection(boolean usePooledConnection) { + if (getConfiguration() instanceof ActiveMQConfiguration activeMQConfiguration) { + activeMQConfiguration.setUsePooledConnection(usePooledConnection); + } + } + + public boolean isUsePooledConnection() { + if (getConfiguration() instanceof ActiveMQConfiguration activeMQConfiguration) { + return activeMQConfiguration.isUsePooledConnection(); + } + return true; + } + + /** + * Enables or disables whether a Spring {@link SingleConnectionFactory} will be used so that when messages are sent + * to ActiveMQ from outside a message consuming thread, pooling will be used rather than the default with the Spring + * {@link JmsTemplate} which will create a new connection, session, producer for each message then close them all + * down again. + * <p/> + * The default value is false and a pooled connection is used by default. + */ + @Metadata(defaultValue = "false", label = "common") + public void setUseSingleConnection(boolean useSingleConnection) { + if (getConfiguration() instanceof ActiveMQConfiguration activeMQConfiguration) { + activeMQConfiguration.setUseSingleConnection(useSingleConnection); + } + } + + public boolean isUseSingleConnection() { + if (getConfiguration() instanceof ActiveMQConfiguration activeMQConfiguration) { + return activeMQConfiguration.isUseSingleConnection(); + } + return false; + } + + @Override + protected void setProperties(Endpoint bean, Map<String, Object> parameters) throws Exception { + Object useSingleConnection = parameters.remove("useSingleConnection"); + if (useSingleConnection != null) { + ((ActiveMQConfiguration) ((JmsEndpoint) bean).getConfiguration()) + .setUseSingleConnection( + PropertyConfigurerSupport.property(getCamelContext(), boolean.class, useSingleConnection)); + } + Object usePooledConnection = parameters.remove("usePooledConnection"); + if (usePooledConnection != null) { + ((ActiveMQConfiguration) ((JmsEndpoint) bean).getConfiguration()) + .setUsePooledConnection( + PropertyConfigurerSupport.property(getCamelContext(), boolean.class, usePooledConnection)); + } + super.setProperties(bean, parameters); + } + + protected void addPooledConnectionFactoryService(Object pooledConnectionFactoryService) { + pooledConnectionFactoryServiceList.add(pooledConnectionFactoryService); + } + + protected void addSingleConnectionFactory(SingleConnectionFactory singleConnectionFactory) { + singleConnectionFactoryList.add(singleConnectionFactory); + } + + @Override + protected String convertPathToActualDestination(String path, Map<String, Object> parameters) { + // support ActiveMQ destination options using the destination. prefix + // http://activemq.apache.org/destination-options.html + Map<String, Object> options = PropertiesHelper.extractProperties(parameters, "destination."); + + String query = URISupport.createQueryString(options); + + // if we have destination options then append them to the destination + // name + if (ObjectHelper.isNotEmpty(query)) { + return path + "?" + query; + } else { + return path; + } + } + + @Override + protected void doInit() throws Exception { + super.doInit(); + + // use OriginalDestinationPropagateStrategy by default if no custom + // strategy has been set + if (getMessageCreatedStrategy() == null) { + setMessageCreatedStrategy(new OriginalDestinationPropagateStrategy()); + } + } + + @Override + protected void doStop() throws Exception { + for (Object s : pooledConnectionFactoryServiceList) { + try { + // invoke stop method if exists + Method m = s.getClass().getMethod("stop"); + org.apache.camel.support.ObjectHelper.invokeMethod(m, s); + } catch (Exception e) { + // ignore + } + } + pooledConnectionFactoryServiceList.clear(); + + for (SingleConnectionFactory s : singleConnectionFactoryList) { + try { + s.destroy(); + } catch (Exception e) { + // ignore + } + } + singleConnectionFactoryList.clear(); + + super.doStop(); + } + + /** + * Configuration of ActiveMQ + */ + @Override + public void setConfiguration(JmsConfiguration configuration) { + if (configuration instanceof ActiveMQConfiguration activeMQConfiguration) { + activeMQConfiguration.setActiveMQComponent(this); + } + super.setConfiguration(configuration); + } + + @Override + protected JmsConfiguration createConfiguration() { + ActiveMQConfiguration answer = new ActiveMQConfiguration(); + answer.setActiveMQComponent(this); + return answer; + } + + @Override + protected JmsEndpoint createTemporaryTopicEndpoint( + String uri, JmsComponent component, String subject, JmsConfiguration configuration) { + return new ActiveMQTemporaryTopicEndpoint(uri, component, subject, configuration); + } + + @Override + protected JmsEndpoint createTopicEndpoint( + String uri, JmsComponent component, String subject, JmsConfiguration configuration) { + return new ActiveMQEndpoint(uri, component, subject, true, configuration); + } + + @Override + protected JmsEndpoint createTemporaryQueueEndpoint( + String uri, JmsComponent component, String subject, JmsConfiguration configuration, + QueueBrowseStrategy queueBrowseStrategy) { + return new ActiveMQTemporaryQueueEndpoint(uri, component, subject, configuration, queueBrowseStrategy); + } + + @Override + protected JmsEndpoint createQueueEndpoint( + String uri, JmsComponent component, String subject, JmsConfiguration configuration, + QueueBrowseStrategy queueBrowseStrategy) { + return new ActiveMQQueueEndpoint(uri, component, subject, configuration, queueBrowseStrategy); + } +} diff --git a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQConfiguration.java b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQConfiguration.java new file mode 100644 index 00000000000..fe5e46535ab --- /dev/null +++ b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQConfiguration.java @@ -0,0 +1,233 @@ +/* + * 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.component.activemq6; + +import java.lang.reflect.Constructor; + +import jakarta.jms.ConnectionFactory; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.camel.CamelContext; +import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.jms.JmsConfiguration; +import org.apache.camel.support.ObjectHelper; +import org.springframework.jms.connection.CachingConnectionFactory; +import org.springframework.jms.connection.DelegatingConnectionFactory; +import org.springframework.jms.connection.JmsTransactionManager; +import org.springframework.jms.connection.SingleConnectionFactory; +import org.springframework.jms.core.JmsTemplate; +import org.springframework.transaction.PlatformTransactionManager; + +public class ActiveMQConfiguration extends JmsConfiguration { + private ActiveMQComponent activeMQComponent; + private String brokerURL = ActiveMQConnectionFactory.DEFAULT_BROKER_URL; + private volatile boolean customBrokerURL; + private boolean useSingleConnection; + private boolean usePooledConnection = true; + private boolean trustAllPackages; + + public ActiveMQConfiguration() { + } + + public String getBrokerURL() { + return brokerURL; + } + + /** + * Sets the broker URL to use to connect to ActiveMQ broker. + */ + public void setBrokerURL(String brokerURL) { + this.brokerURL = brokerURL; + this.customBrokerURL = true; + } + + public boolean isUseSingleConnection() { + return useSingleConnection; + } + + /** + * @see JmsConfiguration#getUsername() + * @deprecated - use JmsConfiguration#getUsername() + */ + @Deprecated(since = "3.0.0") + public String getUserName() { + return getUsername(); + } + + /** + * @see JmsConfiguration#setUsername(String) + * @deprecated - use JmsConfiguration#setUsername(String) + */ + @Deprecated(since = "3.0.0") + public void setUserName(String userName) { + setUsername(userName); + } + + /** + * Enables or disables whether a Spring {@link SingleConnectionFactory} will be used so that when messages are sent + * to ActiveMQ from outside a message-consuming thread, pooling will be used rather than the default with the Spring + * {@link JmsTemplate} which will create a new connection, session, producer for each message then close them all + * down again. + * <p/> + * The default value is false and a pooled connection is used by default. + */ + public void setUseSingleConnection(boolean useSingleConnection) { + this.useSingleConnection = useSingleConnection; + } + + public boolean isUsePooledConnection() { + return usePooledConnection; + } + + /** + * Enables or disables whether a PooledConnectionFactory will be used so that when messages are sent to ActiveMQ + * from outside of a message-consuming thread, pooling will be used rather than the default with the Spring + * {@link JmsTemplate} which will create a new connection, session, producer for each message then close them all + * down again. + * <p/> + * The default value is true. + */ + public void setUsePooledConnection(boolean usePooledConnection) { + this.usePooledConnection = usePooledConnection; + } + + public boolean isTrustAllPackages() { + return trustAllPackages; + } + + /** + * ObjectMessage objects depend on Java serialization of marshal/unmarshal object payload. This process is generally + * considered unsafe as malicious payload can exploit the host system. That's why starting with versions 5.12.2 and + * 5.13.0, ActiveMQ enforces users to explicitly whitelist packages that can be exchanged using ObjectMessages. + * <br/> + * This option can be set to <tt>true</tt> to trust all packages (e.g., whitelist is *). + * <p/> + * See more details at: + * <a href="http://activemq.apache.org/objectmessage.html">http://activemq.apache.org/objectmessage.html</a> + */ + public void setTrustAllPackages(boolean trustAllPackages) { + this.trustAllPackages = trustAllPackages; + } + + /** + * Factory method to create a default transaction manager if one is not specified + */ + @Override + protected PlatformTransactionManager createTransactionManager() { + JmsTransactionManager answer = new JmsTransactionManager(getOrCreateConnectionFactory()); + answer.afterPropertiesSet(); + return answer; + } + + protected void setActiveMQComponent(ActiveMQComponent activeMQComponent) { + this.activeMQComponent = activeMQComponent; + } + + @Override + public void setConnectionFactory(ConnectionFactory connectionFactory) { + ActiveMQConnectionFactory acf = null; + + ConnectionFactory target = connectionFactory; + if (target instanceof CachingConnectionFactory ccf) { + target = ccf.getTargetConnectionFactory(); + } + if (target instanceof DelegatingConnectionFactory dcf) { + target = dcf.getTargetConnectionFactory(); + } + if (target instanceof ActiveMQConnectionFactory) { + acf = (ActiveMQConnectionFactory) target; + } + + if (acf != null) { + if (customBrokerURL) { + // okay, a custom broker url was configured which we want to ensure + // the real target connection factory knows about + acf.setBrokerURL(brokerURL); + } else { + // it's the opposite the target has the brokerURL which we want to set on this + setBrokerURL(acf.getBrokerURL()); + } + } + + super.setConnectionFactory(connectionFactory); + } + + @Override + protected ConnectionFactory createConnectionFactory() { + org.apache.activemq.ActiveMQConnectionFactory answer + = new org.apache.activemq.ActiveMQConnectionFactory(); + answer.setTrustAllPackages(trustAllPackages); + if (getUsername() != null) { + answer.setUserName(getUsername()); + } + if (getPassword() != null) { + answer.setPassword(getPassword()); + } + answer.setBrokerURL(getBrokerURL()); + CamelContext context = activeMQComponent != null ? activeMQComponent.getCamelContext() : null; + if (isUseSingleConnection()) { + SingleConnectionFactory scf = new SingleConnectionFactory(answer); + if (activeMQComponent != null) { + activeMQComponent.addSingleConnectionFactory(scf); + } + return scf; + } else if (isUsePooledConnection()) { + ConnectionFactory pcf = createPooledConnectionFactory(context, answer); + if (activeMQComponent != null) { + activeMQComponent.addPooledConnectionFactoryService(pcf); + } + return pcf; + } else { + return answer; + } + } + + protected ConnectionFactory createPooledConnectionFactory( + CamelContext camelContext, ActiveMQConnectionFactory connectionFactory) { + try { + Class<?> type = loadClass(camelContext, "org.messaginghub.pooled.jms.JmsPoolConnectionFactory", + getClass().getClassLoader()); + + Constructor<?> constructor = type.getConstructor(); + ConnectionFactory cf = (ConnectionFactory) constructor.newInstance(); + ObjectHelper.invokeMethod(type.getDeclaredMethod("setConnectionFactory", Object.class), cf, + connectionFactory); + return cf; + } catch (Exception e) { + throw new RuntimeCamelException("Failed to instantiate PooledConnectionFactory: " + e, e); + } + } + + public static Class<?> loadClass(CamelContext camelContext, String name, ClassLoader loader) throws ClassNotFoundException { + // if camel then use it to load the class + if (camelContext != null) { + return camelContext.getClassResolver() + .resolveMandatoryClass("org.messaginghub.pooled.jms.JmsPoolConnectionFactory"); + } + + ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + if (contextClassLoader != null) { + try { + return contextClassLoader.loadClass(name); + } catch (ClassNotFoundException e) { + return loader.loadClass(name); + } + } else { + return loader.loadClass(name); + } + } +} diff --git a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQEndpoint.java b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQEndpoint.java similarity index 89% copy from components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQEndpoint.java copy to components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQEndpoint.java index 1ba72b7fd65..dc933e7946e 100644 --- a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQEndpoint.java +++ b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQEndpoint.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.component.activemq; +package org.apache.camel.component.activemq6; import java.util.Map; @@ -27,10 +27,10 @@ import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; /** - * Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS component. + * Send messages to (or consume from) Apache ActiveMQ 6.x. This component extends the Camel JMS component. */ -@UriEndpoint(firstVersion = "1.0.0", extendsScheme = "jms", scheme = "activemq", title = "ActiveMQ", - syntax = "activemq:destinationType:destinationName", +@UriEndpoint(firstVersion = "4.7.0", extendsScheme = "jms", scheme = "activemq6", title = "ActiveMQ 6.x", + syntax = "activemq6:destinationType:destinationName", category = { Category.MESSAGING }) public class ActiveMQEndpoint extends JmsEndpoint { diff --git a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQQueueEndpoint.java b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQQueueEndpoint.java new file mode 100644 index 00000000000..c0624ea8613 --- /dev/null +++ b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQQueueEndpoint.java @@ -0,0 +1,101 @@ +/* + * 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.component.activemq6; + +import java.util.Collections; +import java.util.List; + +import org.apache.camel.Exchange; +import org.apache.camel.api.management.ManagedAttribute; +import org.apache.camel.api.management.ManagedResource; +import org.apache.camel.component.jms.DefaultQueueBrowseStrategy; +import org.apache.camel.component.jms.JmsBrowsableEndpoint; +import org.apache.camel.component.jms.JmsComponent; +import org.apache.camel.component.jms.JmsConfiguration; +import org.apache.camel.component.jms.QueueBrowseStrategy; +import org.apache.camel.spi.BrowsableEndpoint; +import org.springframework.jms.core.JmsOperations; + +/** + * An endpoint for a JMS Queue which is also browsable + */ +@ManagedResource(description = "Managed JMS Queue Endpoint") +public class ActiveMQQueueEndpoint extends ActiveMQEndpoint implements JmsBrowsableEndpoint, BrowsableEndpoint { + private int maximumBrowseSize = -1; + private final QueueBrowseStrategy queueBrowseStrategy; + + public ActiveMQQueueEndpoint(String uri, JmsComponent component, String destination, + JmsConfiguration configuration) { + this(uri, component, destination, configuration, null); + setDestinationType("queue"); + } + + public ActiveMQQueueEndpoint(String uri, JmsComponent component, String destination, + JmsConfiguration configuration, QueueBrowseStrategy queueBrowseStrategy) { + super(uri, component, destination, false, configuration); + setDestinationType("queue"); + if (queueBrowseStrategy == null) { + this.queueBrowseStrategy = createQueueBrowseStrategy(); + } else { + this.queueBrowseStrategy = queueBrowseStrategy; + } + } + + public ActiveMQQueueEndpoint(String endpointUri, String destination, QueueBrowseStrategy queueBrowseStrategy) { + super(endpointUri, destination, false); + setDestinationType("queue"); + if (queueBrowseStrategy == null) { + this.queueBrowseStrategy = createQueueBrowseStrategy(); + } else { + this.queueBrowseStrategy = queueBrowseStrategy; + } + } + + public ActiveMQQueueEndpoint(String endpointUri, String destination) { + super(endpointUri, destination, false); + setDestinationType("queue"); + queueBrowseStrategy = createQueueBrowseStrategy(); + } + + @ManagedAttribute + public int getMaximumBrowseSize() { + return maximumBrowseSize; + } + + /** + * If a number is set > 0, then this limits the number of messages that are returned when browsing the queue + */ + @ManagedAttribute + public void setMaximumBrowseSize(int maximumBrowseSize) { + this.maximumBrowseSize = maximumBrowseSize; + } + + @Override + public List<Exchange> getExchanges() { + if (queueBrowseStrategy == null) { + return Collections.emptyList(); + } + String queue = getDestinationName(); + JmsOperations template = getConfiguration().createInOnlyTemplate(this, false, queue); + return queueBrowseStrategy.browse(template, queue, this); + } + + protected QueueBrowseStrategy createQueueBrowseStrategy() { + return new DefaultQueueBrowseStrategy(); + } + +} diff --git a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQSendDynamicAware.java b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQSendDynamicAware.java new file mode 100644 index 00000000000..081223850b4 --- /dev/null +++ b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQSendDynamicAware.java @@ -0,0 +1,25 @@ +/* + * 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.component.activemq6; + +import org.apache.camel.component.jms.JmsSendDynamicAware; +import org.apache.camel.spi.annotations.SendDynamic; + +@SendDynamic("activemq6") +public class ActiveMQSendDynamicAware extends JmsSendDynamicAware { + +} diff --git a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQTemporaryQueueEndpoint.java b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQTemporaryQueueEndpoint.java new file mode 100644 index 00000000000..59c760b69fd --- /dev/null +++ b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQTemporaryQueueEndpoint.java @@ -0,0 +1,39 @@ +/* + * 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.component.activemq6; + +import org.apache.camel.component.jms.JmsComponent; +import org.apache.camel.component.jms.JmsConfiguration; +import org.apache.camel.component.jms.JmsTemporaryQueueEndpoint; +import org.apache.camel.component.jms.QueueBrowseStrategy; + +public class ActiveMQTemporaryQueueEndpoint extends JmsTemporaryQueueEndpoint { + + public ActiveMQTemporaryQueueEndpoint(String uri, JmsComponent component, String destination, + JmsConfiguration configuration) { + super(uri, component, destination, configuration); + } + + public ActiveMQTemporaryQueueEndpoint(String uri, JmsComponent component, String destination, + JmsConfiguration configuration, QueueBrowseStrategy queueBrowseStrategy) { + super(uri, component, destination, configuration, queueBrowseStrategy); + } + + public ActiveMQTemporaryQueueEndpoint(String endpointUri, String destination) { + super(endpointUri, destination); + } +} diff --git a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQTemporaryTopicEndpoint.java b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQTemporaryTopicEndpoint.java new file mode 100644 index 00000000000..bb02c8ff02a --- /dev/null +++ b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/ActiveMQTemporaryTopicEndpoint.java @@ -0,0 +1,33 @@ +/* + * 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.component.activemq6; + +import org.apache.camel.component.jms.JmsComponent; +import org.apache.camel.component.jms.JmsConfiguration; +import org.apache.camel.component.jms.JmsTemporaryTopicEndpoint; + +public class ActiveMQTemporaryTopicEndpoint extends JmsTemporaryTopicEndpoint { + + public ActiveMQTemporaryTopicEndpoint(String uri, JmsComponent component, String destination, + JmsConfiguration configuration) { + super(uri, component, destination, configuration); + } + + public ActiveMQTemporaryTopicEndpoint(String endpointUri, String destination) { + super(endpointUri, destination); + } +} diff --git a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/OriginalDestinationPropagateStrategy.java b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/OriginalDestinationPropagateStrategy.java new file mode 100644 index 00000000000..195fb747bb8 --- /dev/null +++ b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/OriginalDestinationPropagateStrategy.java @@ -0,0 +1,55 @@ +/* + * 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.component.activemq6; + +import jakarta.jms.Message; +import jakarta.jms.Session; + +import org.apache.activemq.command.ActiveMQDestination; +import org.apache.activemq.command.ActiveMQMessage; +import org.apache.camel.Exchange; +import org.apache.camel.component.jms.JmsMessage; +import org.apache.camel.component.jms.MessageCreatedStrategy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A strategy to enrich JMS message with their original destination if the Camel route originates from a JMS + * destination. + */ +public class OriginalDestinationPropagateStrategy implements MessageCreatedStrategy { + + private static final Logger LOG = LoggerFactory.getLogger(OriginalDestinationPropagateStrategy.class); + + @Override + public void onMessageCreated(Message message, Session session, Exchange exchange, Throwable cause) { + if (exchange.getIn() instanceof JmsMessage) { + JmsMessage msg = exchange.getIn(JmsMessage.class); + Message jms = msg.getJmsMessage(); + if (jms instanceof ActiveMQMessage amq && message instanceof ActiveMQMessage) { + if (amq.getOriginalDestination() == null) { + ActiveMQDestination from = amq.getDestination(); + if (from != null) { + LOG.trace("Setting OriginalDestination: {} on {}", from, message); + ((ActiveMQMessage) message).setOriginalDestination(from); + } + } + } + } + } + +} diff --git a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/converter/ActiveMQConverter.java b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/converter/ActiveMQConverter.java new file mode 100644 index 00000000000..e05b4c9a744 --- /dev/null +++ b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/converter/ActiveMQConverter.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.component.activemq6.converter; + +import org.apache.activemq.command.ActiveMQDestination; +import org.apache.camel.Converter; + +@Converter(generateLoader = true) +public class ActiveMQConverter { + + /** + * Converts a URL in ActiveMQ syntax to a destination such as to support "queue://foo.bar" or 'topic://bar.whatnot". + * Things default to queues if no scheme. This allows ActiveMQ destinations to be passed around as Strings and + * converted back again. + * + * @param name is the name of the queue or the full URI using prefixes queue:// or topic:// + * @return the ActiveMQ destination + */ + @Converter + public ActiveMQDestination toDestination(String name) { + return ActiveMQDestination.createDestination(name, ActiveMQDestination.QUEUE_TYPE); + } + +} diff --git a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/converter/ActiveMQMessageConverter.java b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/converter/ActiveMQMessageConverter.java new file mode 100644 index 00000000000..4cdbef0bb15 --- /dev/null +++ b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/converter/ActiveMQMessageConverter.java @@ -0,0 +1,97 @@ +/* + * 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.component.activemq6.converter; + +import java.io.Serializable; + +import jakarta.jms.JMSException; +import jakarta.jms.Message; +import jakarta.jms.MessageListener; + +import org.apache.activemq.command.ActiveMQMessage; +import org.apache.activemq.command.ActiveMQObjectMessage; +import org.apache.activemq.command.ActiveMQTextMessage; +import org.apache.camel.Converter; +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.component.jms.JmsBinding; + +@Converter(generateLoader = true) +public class ActiveMQMessageConverter { + private JmsBinding binding = new JmsBinding(); + + /** + * Converts the inbound message exchange to an ActiveMQ JMS message + * + * @return the ActiveMQ message + */ + @Converter + public ActiveMQMessage toMessage(Exchange exchange) throws JMSException { + ActiveMQMessage message = createActiveMQMessage(exchange); + getBinding().appendJmsProperties(message, exchange); + return message; + } + + /** + * Allows a JMS {@link MessageListener} to be converted to a Camel {@link Processor} so that we can provide better + * <a href="">Bean Integration</a> so that we can use any JMS MessageListener in in Camel as a bean + * + * @param listener the JMS message listener + * @return a newly created Camel Processor which when invoked will invoke + * {@link MessageListener#onMessage(Message)} + */ + @Converter + public Processor toProcessor(final MessageListener listener) { + return new Processor() { + public void process(Exchange exchange) throws Exception { + Message message = toMessage(exchange); + listener.onMessage(message); + } + + @Override + public String toString() { + return "Processor of MessageListener: " + listener; + } + }; + } + + private static ActiveMQMessage createActiveMQMessage(Exchange exchange) throws JMSException { + Object body = exchange.getIn().getBody(); + if (body instanceof String) { + ActiveMQTextMessage answer = new ActiveMQTextMessage(); + answer.setText((String) body); + return answer; + } else if (body instanceof Serializable) { + ActiveMQObjectMessage answer = new ActiveMQObjectMessage(); + answer.setObject((Serializable) body); + return answer; + } else { + return new ActiveMQMessage(); + } + + } + + // Properties + // ------------------------------------------------------------------------- + public JmsBinding getBinding() { + return binding; + } + + public void setBinding(JmsBinding binding) { + this.binding = binding; + } +} diff --git a/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/converter/package.html b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/converter/package.html new file mode 100644 index 00000000000..a1c8201ede9 --- /dev/null +++ b/components/camel-activemq6/src/main/java/org/apache/camel/component/activemq6/converter/package.html @@ -0,0 +1,30 @@ +<!-- + + 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. + +--> +<html> +<head> +</head> +<body> + +Defines the <a href="http://camel.apache.org/type-converter.html">Type Converters</a> for working +with JMS and ActiveMQ with <a href="http://camel.apache.org/">Camel</a> +<a href="http://camel.apache.org/enterprise-integration-patterns.html">Enterprise Integration Patterns</a> + + +</body> +</html> \ No newline at end of file diff --git a/components/camel-activemq6/src/test/java/org/apache/camel/component/activemq6/ActiveMQITSupport.java b/components/camel-activemq6/src/test/java/org/apache/camel/component/activemq6/ActiveMQITSupport.java new file mode 100644 index 00000000000..8d33f81fe16 --- /dev/null +++ b/components/camel-activemq6/src/test/java/org/apache/camel/component/activemq6/ActiveMQITSupport.java @@ -0,0 +1,64 @@ +/* + * 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.component.activemq6; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.camel.test.infra.artemis.services.ArtemisContainer; +import org.apache.camel.test.infra.core.CamelContextExtension; +import org.apache.camel.test.infra.core.DefaultCamelContextExtension; +import org.apache.camel.test.infra.core.api.ConfigurableContext; +import org.apache.camel.test.infra.core.api.ConfigurableRoute; +import org.apache.camel.test.infra.messaging.services.MessagingLocalContainerService; +import org.apache.camel.test.infra.messaging.services.MessagingService; +import org.apache.camel.test.infra.messaging.services.MessagingServiceFactory; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.extension.RegisterExtension; + +public abstract class ActiveMQITSupport implements ConfigurableContext, ConfigurableRoute { + @Order(1) + @RegisterExtension + protected static MessagingService service = MessagingServiceFactory.builder() + .addLocalMapping(ActiveMQITSupport::createLocalService) + .build(); + + @Order(2) + @RegisterExtension + protected static CamelContextExtension contextExtension = new DefaultCamelContextExtension(); + + public static MessagingLocalContainerService<ArtemisContainer> createLocalService() { + ArtemisContainer container = new ArtemisContainer(); + + return new MessagingLocalContainerService<>(container, c -> container.defaultEndpoint()); + } + + /* We don't want topic advisories here: they may cause publication issues (i.e.: + * jakarta.jms.InvalidDestinationException: Cannot publish to a deleted Destination) with + * spring JMS. So, we disable them ... + */ + + public static ActiveMQComponent activeMQComponent(String uri) { + ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(uri); + + connectionFactory.setWatchTopicAdvisories(false); + + ActiveMQConfiguration activeMQConfiguration = new ActiveMQConfiguration(); + activeMQConfiguration.setConnectionFactory(connectionFactory); + + return new ActiveMQComponent(activeMQConfiguration); + } +} diff --git a/components/camel-activemq6/src/test/java/org/apache/camel/component/activemq6/ActiveMQRouteIT.java b/components/camel-activemq6/src/test/java/org/apache/camel/component/activemq6/ActiveMQRouteIT.java new file mode 100644 index 00000000000..60fae2c778d --- /dev/null +++ b/components/camel-activemq6/src/test/java/org/apache/camel/component/activemq6/ActiveMQRouteIT.java @@ -0,0 +1,120 @@ +/* + * 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.component.activemq6; + +import org.apache.camel.CamelContext; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.infra.core.annotations.ContextFixture; +import org.apache.camel.test.infra.core.annotations.RouteFixture; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ActiveMQRouteIT extends ActiveMQITSupport { + + private ProducerTemplate template; + + private MockEndpoint resultEndpoint; + private String expectedBody = "Hello there!"; + + @BeforeEach + void setupTemplate() { + template = contextExtension.getProducerTemplate(); + resultEndpoint = contextExtension.getMockEndpoint("mock:result"); + } + + @Test + public void testJmsQueue() throws Exception { + resultEndpoint.expectedMessageCount(1); + resultEndpoint.message(0).header("cheese").isEqualTo(123); + + template.sendBodyAndHeader("activemq6:queue:jmsQueue", expectedBody, "cheese", 123); + resultEndpoint.assertIsSatisfied(); + } + + @Test + public void testRequestReply() { + String response = template.requestBody("activemq6:queue:inOut", expectedBody, String.class); + assertEquals("response", response); + } + + @Test + public void testJmsTopic() throws Exception { + resultEndpoint.expectedMessageCount(2); + resultEndpoint.message(0).header("cheese").isEqualTo(123); + template.sendBodyAndHeader("activemq6:topic:jmsTopic", expectedBody, "cheese", 123); + resultEndpoint.assertIsSatisfied(); + } + + @Test + public void testPrefixWildcard() throws Exception { + resultEndpoint.expectedMessageCount(1); + template.sendBody("activemq6:queue:wildcard.foo.bar", expectedBody); + resultEndpoint.assertIsSatisfied(); + } + + @Test + public void testIncludeDestination() throws Exception { + resultEndpoint.expectedMessageCount(1); + resultEndpoint.message(0).header("JMSDestination").isEqualTo("queue://jmsQueue"); + template.sendBody("activemq6:queue:jmsQueue", expectedBody); + resultEndpoint.assertIsSatisfied(); + } + + @ContextFixture + public void configureContext(CamelContext context) { + context.addComponent("activemq6", activeMQComponent(service.defaultEndpoint())); + } + + @RouteFixture + public void createRouteBuilder(CamelContext context) throws Exception { + context.addRoutes(createRouteBuilder()); + } + + private static RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + public void configure() { + from("activemq6:queue:jmsQueue") + .to("log:routing") + .to("mock:result"); + + from("activemq6:queue:inOut") + .setBody() + .constant("response"); + + from("activemq6:topic:jmsTopic") + .to("log:routing") + .to("mock:result"); + + from("activemq6:topic:jmsTopic") + .to("log:routing") + .to("mock:result"); + + from("activemq6:queue:wildcard.>") + .to("log:routing") + .to("mock:result"); + + from("activemq6:queue:uriEndpoint") + .to("log:routing") + .to("mock:result"); + } + }; + } +} diff --git a/components/camel-activemq6/src/test/java/org/apache/camel/component/activemq6/ActiveMQToDIT.java b/components/camel-activemq6/src/test/java/org/apache/camel/component/activemq6/ActiveMQToDIT.java new file mode 100644 index 00000000000..727b2d3f8e3 --- /dev/null +++ b/components/camel-activemq6/src/test/java/org/apache/camel/component/activemq6/ActiveMQToDIT.java @@ -0,0 +1,68 @@ +/* + * 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.component.activemq6; + +import org.apache.camel.CamelContext; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.infra.core.annotations.ContextFixture; +import org.apache.camel.test.infra.core.annotations.RouteFixture; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class ActiveMQToDIT extends ActiveMQITSupport { + private ProducerTemplate template; + + @Test + public void testToD() throws Exception { + contextExtension.getMockEndpoint("mock:bar").expectedBodiesReceived("Hello bar"); + contextExtension.getMockEndpoint("mock:beer").expectedBodiesReceived("Hello beer"); + + template.sendBodyAndHeader("direct:start", "Hello bar", "where", "bar"); + template.sendBodyAndHeader("direct:start", "Hello beer", "where", "beer"); + + MockEndpoint.assertIsSatisfied(contextExtension.getContext()); + } + + @BeforeEach + void setupTemplate() { + template = contextExtension.getProducerTemplate(); + } + + @ContextFixture + public void configureContext(CamelContext camelContext) { + camelContext.addComponent("activemq6", activeMQComponent(service.defaultEndpoint())); + } + + @RouteFixture + public void createRouteBuilder(CamelContext context) throws Exception { + context.addRoutes(createRouteBuilder()); + } + + private RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + public void configure() { + // route message dynamic using toD + from("direct:start").toD("activemq6:queue:${header.where}"); + + from("activemq6:queue:bar").to("mock:bar"); + from("activemq6:queue:beer").to("mock:beer"); + } + }; + } +} diff --git a/components/camel-activemq6/src/test/java/org/apache/camel/component/activemq6/ActiveMQToDSendDynamicIT.java b/components/camel-activemq6/src/test/java/org/apache/camel/component/activemq6/ActiveMQToDSendDynamicIT.java new file mode 100644 index 00000000000..d6c0fb8e100 --- /dev/null +++ b/components/camel-activemq6/src/test/java/org/apache/camel/component/activemq6/ActiveMQToDSendDynamicIT.java @@ -0,0 +1,70 @@ +/* + * 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.component.activemq6; + +import org.apache.camel.CamelContext; +import org.apache.camel.ConsumerTemplate; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.infra.core.annotations.ContextFixture; +import org.apache.camel.test.infra.core.annotations.RouteFixture; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ActiveMQToDSendDynamicIT extends ActiveMQITSupport { + private ProducerTemplate template; + private ConsumerTemplate consumer; + + @Test + public void testToD() { + template.sendBodyAndHeader("direct:start", "Hello bar", "where", "bar"); + template.sendBodyAndHeader("direct:start", "Hello beer", "where", "beer"); + + // The messages should be in the queues + String out = consumer.receiveBody("activemq6:queue:bar", 2000, String.class); + assertEquals("Hello bar", out); + out = consumer.receiveBody("activemq6:queue:beer", 2000, String.class); + assertEquals("Hello beer", out); + } + + @BeforeEach + void setupTemplate() { + template = contextExtension.getProducerTemplate(); + consumer = contextExtension.getConsumerTemplate(); + } + + @ContextFixture + public void configureContext(CamelContext camelContext) { + camelContext.addComponent("activemq6", activeMQComponent(service.defaultEndpoint())); + } + + @RouteFixture + public void createRouteBuilder(CamelContext context) throws Exception { + context.addRoutes(createRouteBuilder()); + } + + private RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + public void configure() { + // route message dynamic using toD + from("direct:start").toD("activemq6:queue:${header.where}"); + } + }; + } +} diff --git a/components/camel-activemq6/src/test/resources/log4j2-test.properties b/components/camel-activemq6/src/test/resources/log4j2-test.properties new file mode 100644 index 00000000000..4e071effc65 --- /dev/null +++ b/components/camel-activemq6/src/test/resources/log4j2-test.properties @@ -0,0 +1,28 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +appender.out.type = File +appender.out.name = out +appender.out.fileName = target/camel-activemq6-test.log +appender.out.layout.type = PatternLayout +appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n +appender.stdout.type = Console +appender.stdout.name = stdout +appender.stdout.layout.type = PatternLayout +appender.stdout.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n +rootLogger.level = INFO +rootLogger.appenderRef.out.ref = out diff --git a/components/pom.xml b/components/pom.xml index 6b992f8112c..9ff2502109d 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -75,6 +75,7 @@ <!-- regular modules in alphabetic order --> <module>camel-activemq</module> + <module>camel-activemq6</module> <module>camel-ai</module> <module>camel-amqp</module> <module>camel-arangodb</module> diff --git a/core/camel-main/src/generated/resources/org/apache/camel/main/components.properties b/core/camel-main/src/generated/resources/org/apache/camel/main/components.properties index 73dcf99cd95..eda05e1c4c1 100644 --- a/core/camel-main/src/generated/resources/org/apache/camel/main/components.properties +++ b/core/camel-main/src/generated/resources/org/apache/camel/main/components.properties @@ -1,4 +1,5 @@ activemq +activemq6 amqp arangodb as2 diff --git a/docs/components/modules/ROOT/examples/json/activemq6.json b/docs/components/modules/ROOT/examples/json/activemq6.json new file mode 120000 index 00000000000..8d07a81e368 --- /dev/null +++ b/docs/components/modules/ROOT/examples/json/activemq6.json @@ -0,0 +1 @@ +../../../../../../components/camel-activemq6/src/generated/resources/META-INF/org/apache/camel/component/activemq6/activemq6.json \ No newline at end of file diff --git a/docs/components/modules/ROOT/nav.adoc b/docs/components/modules/ROOT/nav.adoc index b72dc125f25..bbe5ed8bdc5 100644 --- a/docs/components/modules/ROOT/nav.adoc +++ b/docs/components/modules/ROOT/nav.adoc @@ -2,7 +2,8 @@ // make edits in docs/*nav.adoc.template files instead * xref:ROOT:index.adoc[Components] -** xref:activemq-component.adoc[ActiveMQ] +** xref:activemq-component.adoc[ActiveMQ 5.x] +** xref:activemq6-component.adoc[ActiveMQ 6.x] ** xref:amqp-component.adoc[AMQP] ** xref:arangodb-component.adoc[ArangoDb] ** xref:as2-component.adoc[AS2] diff --git a/docs/components/modules/ROOT/pages/activemq6-component.adoc b/docs/components/modules/ROOT/pages/activemq6-component.adoc new file mode 120000 index 00000000000..aee11633719 --- /dev/null +++ b/docs/components/modules/ROOT/pages/activemq6-component.adoc @@ -0,0 +1 @@ +../../../../../components/camel-activemq6/src/main/docs/activemq6-component.adoc \ No newline at end of file diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java index dafaaa0ba88..a0c2327a1c9 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java @@ -46,8 +46,8 @@ import org.apache.camel.builder.component.dsl.*; public interface ComponentsBuilderFactory { /** - * ActiveMQ (camel-activemq) - * Send messages to (or consume from) Apache ActiveMQ. This component + * ActiveMQ 5.x (camel-activemq) + * Send messages to (or consume from) Apache ActiveMQ 5.x. This component * extends the Camel JMS component. * * Category: messaging diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ActivemqComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ActivemqComponentBuilderFactory.java index 50310dbb722..691ba6eb224 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ActivemqComponentBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ActivemqComponentBuilderFactory.java @@ -24,8 +24,8 @@ import org.apache.camel.builder.component.ComponentBuilder; import org.apache.camel.component.activemq.ActiveMQComponent; /** - * Send messages to (or consume from) Apache ActiveMQ. This component extends - * the Camel JMS component. + * Send messages to (or consume from) Apache ActiveMQ 5.x. This component + * extends the Camel JMS component. * * Generated by camel build tools - do NOT edit this file! */ @@ -33,8 +33,8 @@ import org.apache.camel.component.activemq.ActiveMQComponent; public interface ActivemqComponentBuilderFactory { /** - * ActiveMQ (camel-activemq) - * Send messages to (or consume from) Apache ActiveMQ. This component + * ActiveMQ 5.x (camel-activemq) + * Send messages to (or consume from) Apache ActiveMQ 5.x. This component * extends the Camel JMS component. * * Category: messaging @@ -48,7 +48,7 @@ public interface ActivemqComponentBuilderFactory { } /** - * Builder for the ActiveMQ component. + * Builder for the ActiveMQ 5.x component. */ interface ActivemqComponentBuilder extends ComponentBuilder<ActiveMQComponent> { diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java index e4f4a5bf2ee..a4f4808b6a5 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java @@ -27,8 +27,8 @@ import org.apache.camel.builder.endpoint.dsl.*; public class StaticEndpointBuilders { /** - * ActiveMQ (camel-activemq) - * Send messages to (or consume from) Apache ActiveMQ. This component + * ActiveMQ 5.x (camel-activemq) + * Send messages to (or consume from) Apache ActiveMQ 5.x. This component * extends the Camel JMS component. * * Category: messaging @@ -53,8 +53,8 @@ public class StaticEndpointBuilders { return activemq("activemq", path); } /** - * ActiveMQ (camel-activemq) - * Send messages to (or consume from) Apache ActiveMQ. This component + * ActiveMQ 5.x (camel-activemq) + * Send messages to (or consume from) Apache ActiveMQ 5.x. This component * extends the Camel JMS component. * * Category: messaging @@ -80,6 +80,60 @@ public class StaticEndpointBuilders { public static ActiveMQEndpointBuilderFactory.ActiveMQEndpointBuilder activemq(String componentName, String path) { return ActiveMQEndpointBuilderFactory.endpointBuilder(componentName, path); } + /** + * ActiveMQ 6.x (camel-activemq6) + * Send messages to (or consume from) Apache ActiveMQ 6.x. This component + * extends the Camel JMS component. + * + * Category: messaging + * Since: 4.7 + * Maven coordinates: org.apache.camel:camel-activemq6 + * + * Syntax: <code>activemq6:destinationType:destinationName</code> + * + * Path parameter: destinationType + * The kind of destination to use + * Default value: queue + * There are 4 enums and the value can be one of: queue, topic, temp-queue, + * temp-topic + * + * Path parameter: destinationName (required) + * Name of the queue or topic to use as destination + * + * @param path destinationType:destinationName + * @return the dsl builder + */ + public static ActiveMQEndpointBuilderFactory.ActiveMQEndpointBuilder activemq6(String path) { + return activemq6("activemq6", path); + } + /** + * ActiveMQ 6.x (camel-activemq6) + * Send messages to (or consume from) Apache ActiveMQ 6.x. This component + * extends the Camel JMS component. + * + * Category: messaging + * Since: 4.7 + * Maven coordinates: org.apache.camel:camel-activemq6 + * + * Syntax: <code>activemq6:destinationType:destinationName</code> + * + * Path parameter: destinationType + * The kind of destination to use + * Default value: queue + * There are 4 enums and the value can be one of: queue, topic, temp-queue, + * temp-topic + * + * Path parameter: destinationName (required) + * Name of the queue or topic to use as destination + * + * @param componentName to use a custom component name for the endpoint + * instead of the default name + * @param path destinationType:destinationName + * @return the dsl builder + */ + public static ActiveMQEndpointBuilderFactory.ActiveMQEndpointBuilder activemq6(String componentName, String path) { + return ActiveMQEndpointBuilderFactory.endpointBuilder(componentName, path); + } /** * AMQP (camel-amqp) * Messaging with AMQP protocol using Apache QPid Client. diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ActiveMQEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ActiveMQEndpointBuilderFactory.java index d7b8af14294..2ad5b4da24c 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ActiveMQEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ActiveMQEndpointBuilderFactory.java @@ -27,8 +27,8 @@ import org.apache.camel.builder.EndpointProducerBuilder; import org.apache.camel.builder.endpoint.AbstractEndpointBuilder; /** - * Send messages to (or consume from) Apache ActiveMQ. This component extends - * the Camel JMS component. + * Send messages to (or consume from) Apache ActiveMQ 5.x. This component + * extends the Camel JMS component. * * Generated by camel build tools - do NOT edit this file! */ @@ -36,7 +36,7 @@ import org.apache.camel.builder.endpoint.AbstractEndpointBuilder; public interface ActiveMQEndpointBuilderFactory { /** - * Builder for endpoint consumers for the ActiveMQ component. + * Builder for endpoint consumers for the ActiveMQ 5.x component. */ public interface ActiveMQEndpointConsumerBuilder extends @@ -857,7 +857,7 @@ public interface ActiveMQEndpointBuilderFactory { } /** - * Advanced builder for endpoint consumers for the ActiveMQ component. + * Advanced builder for endpoint consumers for the ActiveMQ 5.x component. */ public interface AdvancedActiveMQEndpointConsumerBuilder extends @@ -2649,7 +2649,7 @@ public interface ActiveMQEndpointBuilderFactory { } /** - * Builder for endpoint producers for the ActiveMQ component. + * Builder for endpoint producers for the ActiveMQ 5.x component. */ public interface ActiveMQEndpointProducerBuilder extends @@ -3462,7 +3462,7 @@ public interface ActiveMQEndpointBuilderFactory { } /** - * Advanced builder for endpoint producers for the ActiveMQ component. + * Advanced builder for endpoint producers for the ActiveMQ 5.x component. */ public interface AdvancedActiveMQEndpointProducerBuilder extends EndpointProducerBuilder { default ActiveMQEndpointProducerBuilder basic() { @@ -5103,7 +5103,7 @@ public interface ActiveMQEndpointBuilderFactory { } /** - * Builder for endpoint for the ActiveMQ component. + * Builder for endpoint for the ActiveMQ 5.x component. */ public interface ActiveMQEndpointBuilder extends @@ -5436,7 +5436,7 @@ public interface ActiveMQEndpointBuilderFactory { } /** - * Advanced builder for endpoint for the ActiveMQ component. + * Advanced builder for endpoint for the ActiveMQ 5.x component. */ public interface AdvancedActiveMQEndpointBuilder extends @@ -6729,9 +6729,9 @@ public interface ActiveMQEndpointBuilderFactory { public interface ActiveMQBuilders { /** - * ActiveMQ (camel-activemq) - * Send messages to (or consume from) Apache ActiveMQ. This component - * extends the Camel JMS component. + * ActiveMQ 5.x (camel-activemq) + * Send messages to (or consume from) Apache ActiveMQ 5.x. This + * component extends the Camel JMS component. * * Category: messaging * Since: 1.0 @@ -6743,9 +6743,9 @@ public interface ActiveMQEndpointBuilderFactory { return ActiveMQHeaderNameBuilder.INSTANCE; } /** - * ActiveMQ (camel-activemq) - * Send messages to (or consume from) Apache ActiveMQ. This component - * extends the Camel JMS component. + * ActiveMQ 5.x (camel-activemq) + * Send messages to (or consume from) Apache ActiveMQ 5.x. This + * component extends the Camel JMS component. * * Category: messaging * Since: 1.0 @@ -6769,9 +6769,9 @@ public interface ActiveMQEndpointBuilderFactory { return ActiveMQEndpointBuilderFactory.endpointBuilder("activemq", path); } /** - * ActiveMQ (camel-activemq) - * Send messages to (or consume from) Apache ActiveMQ. This component - * extends the Camel JMS component. + * ActiveMQ 5.x (camel-activemq) + * Send messages to (or consume from) Apache ActiveMQ 5.x. This + * component extends the Camel JMS component. * * Category: messaging * Since: 1.0 @@ -6799,7 +6799,7 @@ public interface ActiveMQEndpointBuilderFactory { } /** - * The builder of headers' name for the ActiveMQ component. + * The builder of headers' name for the ActiveMQ 5.x component. */ public static class ActiveMQHeaderNameBuilder { /** diff --git a/dsl/camel-kamelet-main/src/generated/resources/camel-component-known-dependencies.properties b/dsl/camel-kamelet-main/src/generated/resources/camel-component-known-dependencies.properties index e15f8598f39..9d682b56ca3 100644 --- a/dsl/camel-kamelet-main/src/generated/resources/camel-component-known-dependencies.properties +++ b/dsl/camel-kamelet-main/src/generated/resources/camel-component-known-dependencies.properties @@ -18,6 +18,7 @@ org.apache.camel.FunctionGraphComponent=camel:huaweicloud-functiongraph org.apache.camel.coap.CoAPComponent=camel:coap org.apache.camel.component.activemq.ActiveMQComponent=camel:activemq +org.apache.camel.component.activemq6.ActiveMQComponent=camel:activemq6 org.apache.camel.component.amqp.AMQPComponent=camel:amqp org.apache.camel.component.arangodb.ArangoDbComponent=camel:arangodb org.apache.camel.component.as2.AS2Component=camel:as2 diff --git a/dsl/camel-kamelet-main/src/main/resources/camel-main-known-dependencies.properties b/dsl/camel-kamelet-main/src/main/resources/camel-main-known-dependencies.properties index 4a0d9f654f4..0243764aacc 100644 --- a/dsl/camel-kamelet-main/src/main/resources/camel-main-known-dependencies.properties +++ b/dsl/camel-kamelet-main/src/main/resources/camel-main-known-dependencies.properties @@ -35,6 +35,7 @@ META-INF/services/org/apache/camel/micrometer-prometheus = camel:micrometer-prom META-INF/services/org/apache/camel/cron/cron-service = camel:quartz META-INF/services/org/apache/camel/platform-http/jolokia = camel:camel-platform-http-jolokia org.apache.camel.component.activemq.ActiveMQComponent\:embedded\=true = org.apache.activemq:activemq-broker:5.18.4 +org.apache.camel.component.activemq6.ActiveMQComponent\:embedded\=true = org.apache.activemq:activemq-broker:6.1.2 spring.datasource.url = org.springframework.boot:spring-boot-starter-jdbc:${spring-boot-version} quarkus.datasource.db-kind\=db2 = io.quarkus:quarkus-jdbc-db2:${quarkus-version} quarkus.datasource.db-kind\=derby = io.quarkus:quarkus-jdbc-derby:${quarkus-version} diff --git a/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/ActivemqUriDsl.kt b/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/Activemq6UriDsl.kt similarity index 99% copy from dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/ActivemqUriDsl.kt copy to dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/Activemq6UriDsl.kt index 8f5a1130f71..97b8e315798 100644 --- a/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/ActivemqUriDsl.kt +++ b/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/Activemq6UriDsl.kt @@ -24,22 +24,22 @@ import org.apache.camel.kotlin.CamelDslMarker import org.apache.camel.kotlin.UriDsl /** - * Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS + * Send messages to (or consume from) Apache ActiveMQ 6.x. This component extends the Camel JMS * component. */ -public fun UriDsl.activemq(i: ActivemqUriDsl.() -> Unit) { - ActivemqUriDsl(this).apply(i) +public fun UriDsl.activemq6(i: Activemq6UriDsl.() -> Unit) { + Activemq6UriDsl(this).apply(i) } @CamelDslMarker -public class ActivemqUriDsl( +public class Activemq6UriDsl( it: UriDsl, ) { private val it: UriDsl init { this.it = it - this.it.component("activemq") + this.it.component("activemq6") } private var destinationType: String = "" diff --git a/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/ActivemqUriDsl.kt b/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/ActivemqUriDsl.kt index 8f5a1130f71..1d8adc97dba 100644 --- a/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/ActivemqUriDsl.kt +++ b/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/ActivemqUriDsl.kt @@ -24,7 +24,7 @@ import org.apache.camel.kotlin.CamelDslMarker import org.apache.camel.kotlin.UriDsl /** - * Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS + * Send messages to (or consume from) Apache ActiveMQ 5.x. This component extends the Camel JMS * component. */ public fun UriDsl.activemq(i: ActivemqUriDsl.() -> Unit) { diff --git a/parent/pom.xml b/parent/pom.xml index 111f8d31e4e..a473dbaa41c 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -57,6 +57,7 @@ <!-- dependency versions --> <activemq-version>5.18.4</activemq-version> + <activemq6-version>6.1.2</activemq6-version> <activemq-artemis-version>2.33.0</activemq-artemis-version> <angus-mail-version>2.0.3</angus-mail-version> <apacheds-version>2.0.0.AM26</apacheds-version> @@ -668,6 +669,11 @@ <artifactId>camel-activemq</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-activemq6</artifactId> + <version>${project.version}</version> + </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-amqp</artifactId>