From commits-return-61822-archive-asf-public=cust-asf.ponee.io@camel.apache.org Thu Mar 8 11:45:51 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 8038618067C for ; Thu, 8 Mar 2018 11:45:50 +0100 (CET) Received: (qmail 42625 invoked by uid 500); 8 Mar 2018 10:45:49 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 42425 invoked by uid 99); 8 Mar 2018 10:45:49 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Mar 2018 10:45:49 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id DD23082AB5; Thu, 8 Mar 2018 10:45:48 +0000 (UTC) Date: Thu, 08 Mar 2018 10:45:50 +0000 To: "commits@camel.apache.org" Subject: [camel] 04/05: CAMEL-12330: Allow to configure more option on rabbitmq component level. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: davsclaus@apache.org In-Reply-To: <152050594679.5267.16984148483153927183@gitbox.apache.org> References: <152050594679.5267.16984148483153927183@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: camel X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Rev: 0c0facee6d16e44441b8fb93f3189c2d4e7047b2 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20180308104548.DD23082AB5@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git commit 0c0facee6d16e44441b8fb93f3189c2d4e7047b2 Author: Claus Ibsen AuthorDate: Thu Mar 8 10:28:28 2018 +0100 CAMEL-12330: Allow to configure more option on rabbitmq component level. --- .../src/main/docs/rabbitmq-component.adoc | 8 +++++-- .../component/rabbitmq/RabbitMQComponent.java | 28 ++++++++++++++++++++++ .../camel/component/rabbitmq/RabbitMQEndpoint.java | 7 +++--- .../main/java/sample/camel/SampleCamelRouter.java | 4 ++-- .../src/main/resources/application.properties | 9 +++---- .../springboot/RabbitMQComponentConfiguration.java | 24 +++++++++++++++++++ 6 files changed, 69 insertions(+), 11 deletions(-) diff --git a/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc b/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc index 6fd3f65..35f1e2f 100644 --- a/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc +++ b/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc @@ -37,7 +37,7 @@ exchange name determines which exchange the queue will bind to. === Options // component options: START -The RabbitMQ component supports 3 options which are listed below. +The RabbitMQ component supports 5 options which are listed below. @@ -46,6 +46,8 @@ The RabbitMQ component supports 3 options which are listed below. | Name | Description | Default | Type | *hostname* (common) | The hostname of the running rabbitmq instance or cluster. | | String | *portNumber* (common) | Port number for the host with the running rabbitmq instance or cluster. | 5672 | int +| *username* (security) | Username in case of authenticated access | guest | String +| *password* (security) | Password for authenticated access | guest | String | *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean |=== // component options: END @@ -70,7 +72,7 @@ with the following path and query parameters: |=== -==== Query Parameters (58 parameters): +==== Query Parameters (60 parameters): [width="100%",cols="2,5,^1,2",options="header"] @@ -86,7 +88,9 @@ with the following path and query parameters: | *durable* (common) | If we are declaring a durable exchange (the exchange will survive a server restart) | true | boolean | *exchangeType* (common) | The exchange type such as direct or topic. | direct | String | *exclusive* (common) | Exclusive queues may only be accessed by the current connection, and are deleted when that connection closes. | false | boolean +| *hostname* (common) | The hostname of the running rabbitmq instance or cluster. | | String | *passive* (common) | Passive queues depend on the queue already to be available at RabbitMQ. | false | boolean +| *portNumber* (common) | Port number for the host with the running rabbitmq instance or cluster. Default value is 5672. | | int | *queue* (common) | The queue to receive messages from | | String | *routingKey* (common) | The routing key to use when binding a consumer queue to the exchange. For producer routing keys, you set the header rabbitmq.ROUTING_KEY. | | String | *skipExchangeDeclare* (common) | This can be used if we need to declare the queue but not the exchange | false | boolean 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 2ef6077..39515a3 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 @@ -42,6 +42,10 @@ public class RabbitMQComponent extends UriEndpointComponent { private String hostname; @Metadata(label = "common", defaultValue = "5672") private int portNumber; + @Metadata(label = "security", defaultValue = ConnectionFactory.DEFAULT_USER, secret = true) + private String username = ConnectionFactory.DEFAULT_USER; + @Metadata(label = "security", defaultValue = ConnectionFactory.DEFAULT_PASS, secret = true) + private String password = ConnectionFactory.DEFAULT_PASS; public RabbitMQComponent() { super(RabbitMQEndpoint.class); @@ -89,6 +93,8 @@ public class RabbitMQComponent extends UriEndpointComponent { } endpoint.setHostname(host); endpoint.setPortNumber(port); + endpoint.setUsername(getUsername()); + endpoint.setPassword(getPassword()); endpoint.setExchangeName(exchangeName); endpoint.setClientProperties(clientProperties); endpoint.setTrustManager(trustManager); @@ -135,4 +141,26 @@ public class RabbitMQComponent extends UriEndpointComponent { this.portNumber = portNumber; } + public String getUsername() { + return username; + } + + /** + * Username in case of authenticated access + */ + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + /** + * Password for authenticated access + */ + public void setPassword(String password) { + this.password = password; + } + } diff --git a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java index be24f65..1342a98 100644 --- a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java +++ b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java @@ -53,12 +53,13 @@ public class RabbitMQEndpoint extends DefaultEndpoint implements AsyncEndpoint { // header to indicate that the message body needs to be de-serialized public static final String SERIALIZE_HEADER = "CamelSerialize"; - private String hostname; - private int portNumber; - @UriPath @Metadata(required = "true") private String exchangeName; + @UriParam(label = "common") + private String hostname; + @UriParam(label = "common") + private int portNumber; @UriParam(label = "security", defaultValue = ConnectionFactory.DEFAULT_USER, secret = true) private String username = ConnectionFactory.DEFAULT_USER; @UriParam(label = "security", defaultValue = ConnectionFactory.DEFAULT_PASS, secret = true) diff --git a/examples/camel-example-rabbitmq/src/main/java/sample/camel/SampleCamelRouter.java b/examples/camel-example-rabbitmq/src/main/java/sample/camel/SampleCamelRouter.java index aff28f9..46dfe0c 100644 --- a/examples/camel-example-rabbitmq/src/main/java/sample/camel/SampleCamelRouter.java +++ b/examples/camel-example-rabbitmq/src/main/java/sample/camel/SampleCamelRouter.java @@ -31,9 +31,9 @@ public class SampleCamelRouter extends RouteBuilder { public void configure() throws Exception { from("timer:hello?period=1000") .transform(simple("Random number ${random(0,100)}")) - .to("rabbitmq:{{rabbit-host}}:{{rabbit-port}}/foo?username={{rabbit-user}}&password={{rabbit-password}}"); + .to("rabbitmq:foo"); - from("rabbitmq:{{rabbit-host}}:{{rabbit-port}}/foo?username={{rabbit-user}}&password={{rabbit-password}}") + from("rabbitmq:foo") .log("From RabbitMQ: ${body}"); } diff --git a/examples/camel-example-rabbitmq/src/main/resources/application.properties b/examples/camel-example-rabbitmq/src/main/resources/application.properties index 7d7c800..279b2cd 100644 --- a/examples/camel-example-rabbitmq/src/main/resources/application.properties +++ b/examples/camel-example-rabbitmq/src/main/resources/application.properties @@ -33,10 +33,11 @@ management.security.enabled = false # turn on actuator health check endpoints.health.enabled = true -rabbit-host=localhost -rabbit-port=5672 -rabbit-user=guest -rabbit-password=guest +# configure connection to the rabbit mq broker +camel.component.rabbitmq.hostname=localhost +camel.component.rabbitmq.port-number=5672 +camel.component.rabbitmq.username=guest +camel.component.rabbitmq.password=guest # to configure logging levels #logging.level.org.springframework = INFO diff --git a/platforms/spring-boot/components-starter/camel-rabbitmq-starter/src/main/java/org/apache/camel/component/rabbitmq/springboot/RabbitMQComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-rabbitmq-starter/src/main/java/org/apache/camel/component/rabbitmq/springboot/RabbitMQComponentConfiguration.java index 2796eff..163f892 100644 --- a/platforms/spring-boot/components-starter/camel-rabbitmq-starter/src/main/java/org/apache/camel/component/rabbitmq/springboot/RabbitMQComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-rabbitmq-starter/src/main/java/org/apache/camel/component/rabbitmq/springboot/RabbitMQComponentConfiguration.java @@ -41,6 +41,14 @@ public class RabbitMQComponentConfiguration */ private Integer portNumber = 5672; /** + * Username in case of authenticated access + */ + private String username = "guest"; + /** + * Password for authenticated access + */ + private String password = "guest"; + /** * Whether the component should resolve property placeholders on itself when * starting. Only properties which are of String type can use property * placeholders. @@ -63,6 +71,22 @@ public class RabbitMQComponentConfiguration this.portNumber = portNumber; } + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + public Boolean getResolvePropertyPlaceholders() { return resolvePropertyPlaceholders; } -- To stop receiving notification emails like this one, please contact davsclaus@apache.org.