This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit ecfcbe3508b14ccdca67237e20923cc781872564 Author: Claus Ibsen <[email protected]> AuthorDate: Sun May 2 13:43:54 2021 +0200 CAMEL-16568: camel-activemq - Add destination options to endpoint options --- .../camel/catalog/docs/activemq-component.adoc | 3 +- .../activemq/ActiveMQEndpointConfigurer.java | 37 ++++++++++++++++ .../activemq/ActiveMQEndpointUriFactory.java | 3 +- .../apache/camel/component/activemq/activemq.json | 1 + .../src/main/docs/activemq-component.adoc | 3 +- .../component/activemq/ActiveMQComponent.java | 26 ++++++++++++ .../camel/component/activemq/ActiveMQEndpoint.java | 42 ++++++++++++++++++- .../component/activemq/ActiveMQQueueEndpoint.java} | 21 ++++++---- .../activemq/ActiveMQTemporaryQueueEndpoint.java | 39 +++++++++++++++++ ...nt.java => ActiveMQTemporaryTopicEndpoint.java} | 22 +++++----- .../component/jms/DefaultQueueBrowseStrategy.java | 2 +- ...owseStrategy.java => JmsBrowsableEndpoint.java} | 24 +++++++++-- .../camel/component/jms/JmsQueueEndpoint.java | 2 +- .../camel/component/jms/QueueBrowseStrategy.java | 2 +- .../dsl/ActiveMQEndpointBuilderFactory.java | 49 ++++++++++++++++++++++ .../modules/ROOT/pages/activemq-component.adoc | 3 +- .../packaging/EndpointSchemaGeneratorMojo.java | 16 ------- 17 files changed, 248 insertions(+), 47 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/activemq-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/activemq-component.adoc index 76e9d30..fa20451 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/activemq-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/activemq-component.adoc @@ -188,7 +188,7 @@ with the following path and query parameters: |=== -=== Query Parameters (95 parameters): +=== Query Parameters (96 parameters): [width="100%",cols="2,5,^1,2",options="header"] @@ -218,6 +218,7 @@ with the following path and query parameters: | *allowReplyManagerQuickStop* (consumer) | Whether the DefaultMessageListenerContainer used in the reply managers for request-reply messaging allow the DefaultMessageListenerContainer.runningAllowed flag to quick stop in case JmsConfiguration#isAcceptMessagesWhileStopping is enabled, and org.apache.camel.CamelContext is currently being stopped. This quick stop ability is enabled by default in the regular JMS consumers but to enable for reply managers you must enable this flag. | false | [...] | *consumerType* (consumer) | The consumer type to use, which can be one of: Simple, Default, or Custom. The consumer type determines which Spring JMS listener to use. Default will use org.springframework.jms.listener.DefaultMessageListenerContainer, Simple will use org.springframework.jms.listener.SimpleMessageListenerContainer. When Custom is specified, the MessageListenerContainerFactory defined by the messageListenerContainerFactory option will determine what org.springframework.jms. [...] | *defaultTaskExecutorType* (consumer) | Specifies what default TaskExecutor type to use in the DefaultMessageListenerContainer, for both consumer endpoints and the ReplyTo consumer of producer endpoints. Possible values: SimpleAsync (uses Spring's SimpleAsyncTaskExecutor) or ThreadPool (uses Spring's ThreadPoolTaskExecutor with optimal values - cached threadpool-like). If not set, it defaults to the previous behaviour, which uses a cached thread pool for consumer endpoints and SimpleAsy [...] +| *destinationOptions* (consumer) | Destination Options are a way to provide extended configuration options to a JMS consumer without having to extend the JMS API. The options are encoded using URL query syntax in the destination name that the consumer is created on. See more details at \https://activemq.apache.org/destination-options. | | Map | *eagerLoadingOfProperties* (consumer) | Enables eager loading of JMS properties and payload as soon as a message is loaded which generally is inefficient as the JMS properties may not be required but sometimes can catch early any issues with the underlying JMS provider and the use of JMS properties. See also the option eagerPoisonBody. | false | boolean | *eagerPoisonBody* (consumer) | If eagerLoadingOfProperties is enabled and the JMS message payload (JMS body or JMS properties) is poison (cannot be read/mapped), then set this text as the message body instead so the message can be processed (the cause of the poison are already stored as exception on the Exchange). This can be turned off by setting eagerPoisonBody=false. See also the option eagerLoadingOfProperties. | Poison JMS message due to ${exception.message} | String | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler diff --git a/components/camel-activemq/src/generated/java/org/apache/camel/component/activemq/ActiveMQEndpointConfigurer.java b/components/camel-activemq/src/generated/java/org/apache/camel/component/activemq/ActiveMQEndpointConfigurer.java index 42a3132..7f560dd 100644 --- a/components/camel-activemq/src/generated/java/org/apache/camel/component/activemq/ActiveMQEndpointConfigurer.java +++ b/components/camel-activemq/src/generated/java/org/apache/camel/component/activemq/ActiveMQEndpointConfigurer.java @@ -17,5 +17,42 @@ import org.apache.camel.component.jms.JmsEndpointConfigurer; @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-activemq/src/generated/java/org/apache/camel/component/activemq/ActiveMQEndpointUriFactory.java b/components/camel-activemq/src/generated/java/org/apache/camel/component/activemq/ActiveMQEndpointUriFactory.java index 105b940..95f9378 100644 --- a/components/camel-activemq/src/generated/java/org/apache/camel/component/activemq/ActiveMQEndpointUriFactory.java +++ b/components/camel-activemq/src/generated/java/org/apache/camel/component/activemq/ActiveMQEndpointUriFactory.java @@ -20,7 +20,7 @@ public class ActiveMQEndpointUriFactory extends org.apache.camel.support.compone private static final Set<String> PROPERTY_NAMES; private static final Set<String> SECRET_PROPERTY_NAMES; static { - Set<String> props = new HashSet<>(97); + Set<String> props = new HashSet<>(98); props.add("includeSentJMSMessageID"); props.add("asyncConsumer"); props.add("mapJmsMessage"); @@ -89,6 +89,7 @@ public class ActiveMQEndpointUriFactory extends org.apache.camel.support.compone props.add("destinationResolver"); props.add("exceptionHandler"); props.add("idleConsumerLimit"); + props.add("destinationOptions"); props.add("explicitQosEnabled"); props.add("transacted"); props.add("transactionName"); diff --git a/components/camel-activemq/src/generated/resources/org/apache/camel/component/activemq/activemq.json b/components/camel-activemq/src/generated/resources/org/apache/camel/component/activemq/activemq.json index fb1575c..fee4074 100644 --- a/components/camel-activemq/src/generated/resources/org/apache/camel/component/activemq/activemq.json +++ b/components/camel-activemq/src/generated/resources/org/apache/camel/component/activemq/activemq.json @@ -152,6 +152,7 @@ "allowReplyManagerQuickStop": { "kind": "parameter", "displayName": "Allow Reply Manager Quick Stop", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.jms.JmsConfiguration", "configurationField": "configuration", "description": "Whether the DefaultMessageListenerContainer used in th [...] "consumerType": { "kind": "parameter", "displayName": "Consumer Type", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.jms.ConsumerType", "enum": [ "Simple", "Default", "Custom" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "Default", "configurationClass": "org.apache.camel.component.jms.JmsConfiguration", "configurationField": "configuration", "description": "The [...] "defaultTaskExecutorType": { "kind": "parameter", "displayName": "Default Task Executor Type", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.jms.DefaultTaskExecutorType", "enum": [ "ThreadPool", "SimpleAsync" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.jms.JmsConfiguration", "configurationField": "configuration", "description" [...] + "destinationOptions": { "kind": "parameter", "displayName": "Destination Options", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "java.util.Map<java.lang.String, java.lang.String>", "prefix": "destination.", "multiValue": true, "deprecated": false, "autowired": false, "secret": false, "description": "Destination Options are a way to provide extended configuration options to a JMS consumer without having to extend the JM [...] "eagerLoadingOfProperties": { "kind": "parameter", "displayName": "Eager Loading Of Properties", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.jms.JmsConfiguration", "configurationField": "configuration", "description": "Enables eager loading of JMS properties and payload as soon [...] "eagerPoisonBody": { "kind": "parameter", "displayName": "Eager Poison Body", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "Poison JMS message due to ${exception.message}", "configurationClass": "org.apache.camel.component.jms.JmsConfiguration", "configurationField": "configuration", "description": "If eagerLoadingOfProperties [...] "exceptionHandler": { "kind": "parameter", "displayName": "Exception Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", "deprecated": false, "autowired": false, "secret": false, "description": "To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the con [...] diff --git a/components/camel-activemq/src/main/docs/activemq-component.adoc b/components/camel-activemq/src/main/docs/activemq-component.adoc index 76e9d30..fa20451 100644 --- a/components/camel-activemq/src/main/docs/activemq-component.adoc +++ b/components/camel-activemq/src/main/docs/activemq-component.adoc @@ -188,7 +188,7 @@ with the following path and query parameters: |=== -=== Query Parameters (95 parameters): +=== Query Parameters (96 parameters): [width="100%",cols="2,5,^1,2",options="header"] @@ -218,6 +218,7 @@ with the following path and query parameters: | *allowReplyManagerQuickStop* (consumer) | Whether the DefaultMessageListenerContainer used in the reply managers for request-reply messaging allow the DefaultMessageListenerContainer.runningAllowed flag to quick stop in case JmsConfiguration#isAcceptMessagesWhileStopping is enabled, and org.apache.camel.CamelContext is currently being stopped. This quick stop ability is enabled by default in the regular JMS consumers but to enable for reply managers you must enable this flag. | false | [...] | *consumerType* (consumer) | The consumer type to use, which can be one of: Simple, Default, or Custom. The consumer type determines which Spring JMS listener to use. Default will use org.springframework.jms.listener.DefaultMessageListenerContainer, Simple will use org.springframework.jms.listener.SimpleMessageListenerContainer. When Custom is specified, the MessageListenerContainerFactory defined by the messageListenerContainerFactory option will determine what org.springframework.jms. [...] | *defaultTaskExecutorType* (consumer) | Specifies what default TaskExecutor type to use in the DefaultMessageListenerContainer, for both consumer endpoints and the ReplyTo consumer of producer endpoints. Possible values: SimpleAsync (uses Spring's SimpleAsyncTaskExecutor) or ThreadPool (uses Spring's ThreadPoolTaskExecutor with optimal values - cached threadpool-like). If not set, it defaults to the previous behaviour, which uses a cached thread pool for consumer endpoints and SimpleAsy [...] +| *destinationOptions* (consumer) | Destination Options are a way to provide extended configuration options to a JMS consumer without having to extend the JMS API. The options are encoded using URL query syntax in the destination name that the consumer is created on. See more details at \https://activemq.apache.org/destination-options. | | Map | *eagerLoadingOfProperties* (consumer) | Enables eager loading of JMS properties and payload as soon as a message is loaded which generally is inefficient as the JMS properties may not be required but sometimes can catch early any issues with the underlying JMS provider and the use of JMS properties. See also the option eagerPoisonBody. | false | boolean | *eagerPoisonBody* (consumer) | If eagerLoadingOfProperties is enabled and the JMS message payload (JMS body or JMS properties) is poison (cannot be read/mapped), then set this text as the message body instead so the message can be processed (the cause of the poison are already stored as exception on the Exchange). This can be turned off by setting eagerPoisonBody=false. See also the option eagerLoadingOfProperties. | Poison JMS message due to ${exception.message} | String | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler diff --git a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQComponent.java b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQComponent.java index d5ffacc..f74ffa5 100644 --- a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQComponent.java +++ b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQComponent.java @@ -27,6 +27,7 @@ import org.apache.camel.RuntimeCamelException; 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; @@ -261,4 +262,29 @@ public class ActiveMQComponent extends JmsComponent { 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-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 75ddcce..1ba72b7 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 @@ -16,9 +16,15 @@ */ package org.apache.camel.component.activemq; +import java.util.Map; + import org.apache.camel.Category; +import org.apache.camel.component.jms.JmsBinding; +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.spi.UriEndpoint; +import org.apache.camel.spi.UriParam; /** * Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS component. @@ -28,6 +34,40 @@ import org.apache.camel.spi.UriEndpoint; category = { Category.MESSAGING }) public class ActiveMQEndpoint extends JmsEndpoint { - // needed for component documentation + @UriParam(multiValue = true, prefix = "destination.", label = "consumer,advanced") + private Map<String, String> destinationOptions; + + public ActiveMQEndpoint() { + } + + public ActiveMQEndpoint(String uri, JmsComponent component, String destinationName, boolean pubSubDomain, + JmsConfiguration configuration) { + super(uri, component, destinationName, pubSubDomain, configuration); + } + + public ActiveMQEndpoint(String endpointUri, JmsBinding binding, JmsConfiguration configuration, String destinationName, + boolean pubSubDomain) { + super(endpointUri, binding, configuration, destinationName, pubSubDomain); + } + + public ActiveMQEndpoint(String endpointUri, String destinationName, boolean pubSubDomain) { + super(endpointUri, destinationName, pubSubDomain); + } + + public ActiveMQEndpoint(String endpointUri, String destinationName) { + super(endpointUri, destinationName); + } + + public Map<String, String> getDestinationOptions() { + return destinationOptions; + } + /** + * Destination Options are a way to provide extended configuration options to a JMS consumer without having to + * extend the JMS API. The options are encoded using URL query syntax in the destination name that the consumer is + * created on. See more details at https://activemq.apache.org/destination-options. + */ + public void setDestinationOptions(Map<String, String> destinationOptions) { + this.destinationOptions = destinationOptions; + } } diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQQueueEndpoint.java similarity index 75% copy from components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java copy to components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQQueueEndpoint.java index bb1f4d7..d7449dc 100644 --- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java +++ b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQQueueEndpoint.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.component.jms; +package org.apache.camel.component.activemq; import java.util.Collections; import java.util.List; @@ -24,6 +24,11 @@ import javax.jms.Queue; 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; @@ -31,18 +36,18 @@ import org.springframework.jms.core.JmsOperations; * An endpoint for a JMS Queue which is also browsable */ @ManagedResource(description = "Managed JMS Queue Endpoint") -public class JmsQueueEndpoint extends JmsEndpoint implements BrowsableEndpoint { +public class ActiveMQQueueEndpoint extends ActiveMQEndpoint implements JmsBrowsableEndpoint, BrowsableEndpoint { private int maximumBrowseSize = -1; private final QueueBrowseStrategy queueBrowseStrategy; - public JmsQueueEndpoint(String uri, JmsComponent component, String destination, - JmsConfiguration configuration) { + public ActiveMQQueueEndpoint(String uri, JmsComponent component, String destination, + JmsConfiguration configuration) { this(uri, component, destination, configuration, null); setDestinationType("queue"); } - public JmsQueueEndpoint(String uri, JmsComponent component, String destination, - JmsConfiguration configuration, QueueBrowseStrategy queueBrowseStrategy) { + public ActiveMQQueueEndpoint(String uri, JmsComponent component, String destination, + JmsConfiguration configuration, QueueBrowseStrategy queueBrowseStrategy) { super(uri, component, destination, false, configuration); setDestinationType("queue"); if (queueBrowseStrategy == null) { @@ -52,7 +57,7 @@ public class JmsQueueEndpoint extends JmsEndpoint implements BrowsableEndpoint { } } - public JmsQueueEndpoint(String endpointUri, String destination, QueueBrowseStrategy queueBrowseStrategy) { + public ActiveMQQueueEndpoint(String endpointUri, String destination, QueueBrowseStrategy queueBrowseStrategy) { super(endpointUri, destination, false); setDestinationType("queue"); if (queueBrowseStrategy == null) { @@ -62,7 +67,7 @@ public class JmsQueueEndpoint extends JmsEndpoint implements BrowsableEndpoint { } } - public JmsQueueEndpoint(String endpointUri, String destination) { + public ActiveMQQueueEndpoint(String endpointUri, String destination) { super(endpointUri, destination, false); setDestinationType("queue"); queueBrowseStrategy = createQueueBrowseStrategy(); diff --git a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQTemporaryQueueEndpoint.java b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQTemporaryQueueEndpoint.java new file mode 100644 index 0000000..84839df --- /dev/null +++ b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/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.activemq; + +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-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQEndpoint.java b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQTemporaryTopicEndpoint.java similarity index 57% copy from components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQEndpoint.java copy to components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQTemporaryTopicEndpoint.java index 75ddcce..3534218 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/ActiveMQTemporaryTopicEndpoint.java @@ -16,18 +16,18 @@ */ package org.apache.camel.component.activemq; -import org.apache.camel.Category; -import org.apache.camel.component.jms.JmsEndpoint; -import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.component.jms.JmsComponent; +import org.apache.camel.component.jms.JmsConfiguration; +import org.apache.camel.component.jms.JmsTemporaryTopicEndpoint; -/** - * Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS component. - */ -@UriEndpoint(firstVersion = "1.0.0", extendsScheme = "jms", scheme = "activemq", title = "ActiveMQ", - syntax = "activemq:destinationType:destinationName", - category = { Category.MESSAGING }) -public class ActiveMQEndpoint extends JmsEndpoint { +public class ActiveMQTemporaryTopicEndpoint extends JmsTemporaryTopicEndpoint { - // needed for component documentation + 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-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java index 8f07b9b..7b3648d 100644 --- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java +++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/DefaultQueueBrowseStrategy.java @@ -32,7 +32,7 @@ import org.springframework.jms.core.JmsOperations; public class DefaultQueueBrowseStrategy implements QueueBrowseStrategy { @Override - public List<Exchange> browse(JmsOperations template, String queue, final JmsQueueEndpoint endpoint) { + public List<Exchange> browse(JmsOperations template, String queue, final JmsBrowsableEndpoint endpoint) { if (endpoint.getSelector() != null) { return template.browseSelected(queue, endpoint.getSelector(), (session, browser) -> { int size = endpoint.getMaximumBrowseSize(); diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBrowsableEndpoint.java similarity index 63% copy from components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java copy to components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBrowsableEndpoint.java index abfa7e6..bc4dcfd 100644 --- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java +++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBrowsableEndpoint.java @@ -16,13 +16,29 @@ */ package org.apache.camel.component.jms; -import java.util.List; +import javax.jms.Message; +import javax.jms.Session; import org.apache.camel.Exchange; -import org.springframework.jms.core.JmsOperations; -public interface QueueBrowseStrategy { +/** + * JMS endpoint which is browsable. + */ +public interface JmsBrowsableEndpoint { + + /** + * If a number is set > 0 then this limits the number of messages that are returned when browsing the queue + */ + int getMaximumBrowseSize(); + + /** + * The JMS selector to use (if any) + */ + String getSelector(); - List<Exchange> browse(JmsOperations template, String queue, JmsQueueEndpoint endpoint); + /** + * To create exchange for the messages to be browsed. + */ + Exchange createExchange(Message message, Session session); } diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java index bb1f4d7..6d8647a 100644 --- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java +++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java @@ -31,7 +31,7 @@ import org.springframework.jms.core.JmsOperations; * An endpoint for a JMS Queue which is also browsable */ @ManagedResource(description = "Managed JMS Queue Endpoint") -public class JmsQueueEndpoint extends JmsEndpoint implements BrowsableEndpoint { +public class JmsQueueEndpoint extends JmsEndpoint implements JmsBrowsableEndpoint, BrowsableEndpoint { private int maximumBrowseSize = -1; private final QueueBrowseStrategy queueBrowseStrategy; diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java index abfa7e6..fb45438 100644 --- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java +++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/QueueBrowseStrategy.java @@ -23,6 +23,6 @@ import org.springframework.jms.core.JmsOperations; public interface QueueBrowseStrategy { - List<Exchange> browse(JmsOperations template, String queue, JmsQueueEndpoint endpoint); + List<Exchange> browse(JmsOperations template, String queue, JmsBrowsableEndpoint endpoint); } diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ActiveMQEndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ActiveMQEndpointBuilderFactory.java index d4a75f1..4f8361c 100644 --- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ActiveMQEndpointBuilderFactory.java +++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ActiveMQEndpointBuilderFactory.java @@ -16,6 +16,7 @@ */ package org.apache.camel.builder.endpoint.dsl; +import java.util.Map; import javax.annotation.Generated; import org.apache.camel.ExchangePattern; import org.apache.camel.LoggingLevel; @@ -1107,6 +1108,54 @@ public interface ActiveMQEndpointBuilderFactory { return this; } /** + * Destination Options are a way to provide extended configuration + * options to a JMS consumer without having to extend the JMS API. The + * options are encoded using URL query syntax in the destination name + * that the consumer is created on. See more details at + * https://activemq.apache.org/destination-options. + * + * The option is a: <code>java.util.Map&lt;java.lang.String, + * java.lang.String&gt;</code> type. + * The option is multivalued, and you can use the + * destinationOptions(String, Object) method to add a value (call the + * method multiple times to set more values). + * + * Group: consumer (advanced) + * + * @param key the option key + * @param value the option value + * @return the dsl builder + */ + default AdvancedActiveMQEndpointConsumerBuilder destinationOptions( + String key, + Object value) { + doSetMultiValueProperty("destinationOptions", "destination." + key, value); + return this; + } + /** + * Destination Options are a way to provide extended configuration + * options to a JMS consumer without having to extend the JMS API. The + * options are encoded using URL query syntax in the destination name + * that the consumer is created on. See more details at + * https://activemq.apache.org/destination-options. + * + * The option is a: <code>java.util.Map&lt;java.lang.String, + * java.lang.String&gt;</code> type. + * The option is multivalued, and you can use the + * destinationOptions(String, Object) method to add a value (call the + * method multiple times to set more values). + * + * Group: consumer (advanced) + * + * @param values the values + * @return the dsl builder + */ + default AdvancedActiveMQEndpointConsumerBuilder destinationOptions( + Map values) { + doSetMultiValueProperties("destinationOptions", "destination.", values); + return this; + } + /** * Enables eager loading of JMS properties and payload as soon as a * message is loaded which generally is inefficient as the JMS * properties may not be required but sometimes can catch early any diff --git a/docs/components/modules/ROOT/pages/activemq-component.adoc b/docs/components/modules/ROOT/pages/activemq-component.adoc index a3e128e..5025df1 100644 --- a/docs/components/modules/ROOT/pages/activemq-component.adoc +++ b/docs/components/modules/ROOT/pages/activemq-component.adoc @@ -190,7 +190,7 @@ with the following path and query parameters: |=== -=== Query Parameters (95 parameters): +=== Query Parameters (96 parameters): [width="100%",cols="2,5,^1,2",options="header"] @@ -220,6 +220,7 @@ with the following path and query parameters: | *allowReplyManagerQuickStop* (consumer) | Whether the DefaultMessageListenerContainer used in the reply managers for request-reply messaging allow the DefaultMessageListenerContainer.runningAllowed flag to quick stop in case JmsConfiguration#isAcceptMessagesWhileStopping is enabled, and org.apache.camel.CamelContext is currently being stopped. This quick stop ability is enabled by default in the regular JMS consumers but to enable for reply managers you must enable this flag. | false | [...] | *consumerType* (consumer) | The consumer type to use, which can be one of: Simple, Default, or Custom. The consumer type determines which Spring JMS listener to use. Default will use org.springframework.jms.listener.DefaultMessageListenerContainer, Simple will use org.springframework.jms.listener.SimpleMessageListenerContainer. When Custom is specified, the MessageListenerContainerFactory defined by the messageListenerContainerFactory option will determine what org.springframework.jms. [...] | *defaultTaskExecutorType* (consumer) | Specifies what default TaskExecutor type to use in the DefaultMessageListenerContainer, for both consumer endpoints and the ReplyTo consumer of producer endpoints. Possible values: SimpleAsync (uses Spring's SimpleAsyncTaskExecutor) or ThreadPool (uses Spring's ThreadPoolTaskExecutor with optimal values - cached threadpool-like). If not set, it defaults to the previous behaviour, which uses a cached thread pool for consumer endpoints and SimpleAsy [...] +| *destinationOptions* (consumer) | Destination Options are a way to provide extended configuration options to a JMS consumer without having to extend the JMS API. The options are encoded using URL query syntax in the destination name that the consumer is created on. See more details at \https://activemq.apache.org/destination-options. | | Map | *eagerLoadingOfProperties* (consumer) | Enables eager loading of JMS properties and payload as soon as a message is loaded which generally is inefficient as the JMS properties may not be required but sometimes can catch early any issues with the underlying JMS provider and the use of JMS properties. See also the option eagerPoisonBody. | false | boolean | *eagerPoisonBody* (consumer) | If eagerLoadingOfProperties is enabled and the JMS message payload (JMS body or JMS properties) is poison (cannot be read/mapped), then set this text as the message body instead so the message can be processed (the cause of the poison are already stored as exception on the Exchange). This can be turned off by setting eagerPoisonBody=false. See also the option eagerLoadingOfProperties. | Poison JMS message due to ${exception.message} | String | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointSchemaGeneratorMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointSchemaGeneratorMojo.java index d12c4b8..4f67567 100644 --- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointSchemaGeneratorMojo.java +++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointSchemaGeneratorMojo.java @@ -251,22 +251,6 @@ public class EndpointSchemaGeneratorMojo extends AbstractGeneratorMojo { // endpoint options findClassProperties(componentModel, classElement, new HashSet<>(), "", null, null, false); - // special for activemq - if ("activemq".equals(componentModel.getScheme())) { - EndpointOptionModel option = new EndpointOptionModel(); - option.setName("destinationOptions"); - option.setKind("parameter"); - option.setDisplayName("Destination Options"); - option.setGroup("consumer (advanced)"); - option.setLabel("consumer,advanced"); - option.setType("object"); - option.setJavaType("java.util.Map<java.lang.String, java.lang.String>"); - option.setPrefix("destination."); - option.setMultiValue(true); - option.setDescription("Destination options are a way to provide extended configuration options to a JMS consumer without having to extend the JMS API. The options are encoded using URL query syntax in the destination name that the consumer is created on. See more details at https://activemq.apache.org/destination-options."); - componentModel.addEndpointOption(option); - } - String excludedEndpointProperties = ""; Metadata endpointMetadata = classElement.getAnnotation(Metadata.class); if (endpointMetadata != null) {
