This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-3.0.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.0.x by this push: new dcb4f22 CAMEL-14242: Fix binding parameters with arg.- is not possible when using endpointdsl and RabbitMQ. Thaks to Michael Elbaz for reporting and with a PR with a try fix. dcb4f22 is described below commit dcb4f2292c2183c3079e570afd4488bf45b86af4 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu Dec 5 13:39:58 2019 +0100 CAMEL-14242: Fix binding parameters with arg.- is not possible when using endpointdsl and RabbitMQ. Thaks to Michael Elbaz for reporting and with a PR with a try fix. --- components/camel-rabbitmq/pom.xml | 5 ++ .../component/rabbitmq/RabbitMQComponent.java | 7 ++- .../rabbitmq/RabbitMQEndpointDSLTest.java | 54 ++++++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/components/camel-rabbitmq/pom.xml b/components/camel-rabbitmq/pom.xml index ceab3c9..5678e5b 100644 --- a/components/camel-rabbitmq/pom.xml +++ b/components/camel-rabbitmq/pom.xml @@ -54,6 +54,11 @@ <!-- testing --> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-endpointdsl</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-test-spring</artifactId> <scope>test</scope> </dependency> diff --git a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQComponent.java b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQComponent.java index 3172b24..e0d4b37 100644 --- a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQComponent.java +++ b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQComponent.java @@ -254,7 +254,12 @@ public class RabbitMQComponent extends DefaultComponent { localArgs.putAll(getArgs()); } localArgs.putAll(PropertiesHelper.extractProperties(params, ARG_PREFIX)); - endpoint.setArgs(localArgs); + Map<String, Object> existing = endpoint.getArgs(); + if (existing != null) { + existing.putAll(localArgs); + } else { + endpoint.setArgs(localArgs); + } // Change null headers processing for message converter endpoint.getMessageConverter().setAllowNullHeaders(endpoint.isAllowNullHeaders()); diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointDSLTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointDSLTest.java new file mode 100644 index 0000000..920d57e --- /dev/null +++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointDSLTest.java @@ -0,0 +1,54 @@ +/* + * 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.rabbitmq; + +import java.util.Collections; +import java.util.Map; + +import org.apache.camel.Endpoint; +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.endpoint.EndpointRouteBuilder; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class RabbitMQEndpointDSLTest extends CamelTestSupport { + + @Test + public void testRabbitMQEndpointDsl() throws Exception { + Endpoint e = context.getEndpoints().stream().filter(RabbitMQEndpoint.class::isInstance).findFirst().get(); + assertNotNull(e); + + RabbitMQEndpoint re = (RabbitMQEndpoint) e; + assertNotNull(re.getArgs()); + + Map map = re.getArgs(); + assertEquals(1, map.size()); + assertEquals("queue.x-max-priority", map.keySet().iterator().next()); + assertEquals("10", map.values().iterator().next()); + } + + @Override + protected RoutesBuilder createRouteBuilder() throws Exception { + return new EndpointRouteBuilder() { + @Override + public void configure() throws Exception { + from(direct("start")) + .to(rabbitmq("foo").advanced().args(Collections.singletonMap("queue.x-max-priority", "10"))); + } + }; + } +}