camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [1/2] camel git commit: CAMEL-10166: Add URI parameter skip QueueBind in case we need to declare a queue but not bind it to the exchange
Date Tue, 26 Jul 2016 11:20:09 GMT
Repository: camel
Updated Branches:
  refs/heads/master 11b0e39fd -> d57797c33


CAMEL-10166: Add URI parameter skip QueueBind in case we need to declare a queue but not bind
it to the exchange


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ade42700
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ade42700
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ade42700

Branch: refs/heads/master
Commit: ade427001b71ef6c2ef6974ec54c1ebfdd07ce27
Parents: 11b0e39
Author: Fabian Chanton <fabian.chanton@misurio.ch>
Authored: Tue Jul 26 13:01:17 2016 +0200
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Tue Jul 26 13:19:40 2016 +0200

----------------------------------------------------------------------
 .../camel-rabbitmq/src/main/docs/rabbitmq.adoc      |  5 ++++-
 .../component/rabbitmq/RabbitMQDeclareSupport.java  |  8 +++++++-
 .../camel/component/rabbitmq/RabbitMQEndpoint.java  | 16 +++++++++++++++-
 .../component/rabbitmq/RabbitMQEndpointTest.java    |  6 ++++++
 4 files changed, 32 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ade42700/components/camel-rabbitmq/src/main/docs/rabbitmq.adoc
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/main/docs/rabbitmq.adoc b/components/camel-rabbitmq/src/main/docs/rabbitmq.adoc
index 2e59a32..aeade1d 100644
--- a/components/camel-rabbitmq/src/main/docs/rabbitmq.adoc
+++ b/components/camel-rabbitmq/src/main/docs/rabbitmq.adoc
@@ -48,8 +48,9 @@ The RabbitMQ component has no options.
 
 
 
+
 // endpoint options: START
-The RabbitMQ component supports 53 endpoint options which are listed below:
+The RabbitMQ component supports 54 endpoint options which are listed below:
 
 {% raw %}
 [width="100%",cols="2s,1,1m,1m,5",options="header"]
@@ -70,6 +71,7 @@ The RabbitMQ component supports 53 endpoint options which are listed below:
 | queue | common |  | String | The queue to receive messages from
 | routingKey | common |  | String | The routing key to use when binding a consumer queue
to the exchange. For producer routing keys you set the header rabbitmq.ROUTING_KEY.
 | skipExchangeDeclare | common | false | boolean | This can be used if we need to declare
the queue but not the exchange
+| skipQueueBind | common | false | boolean | If true the queue will not be bound to the exchange
after declaring it
 | skipQueueDeclare | common | false | boolean | If true the producer will not declare and
bind a queue. This can be used for directing messages via an existing routing key.
 | vhost | common | / | String | The vhost for the channel
 | autoAck | consumer | true | boolean | If messages should be auto acknowledged
@@ -113,6 +115,7 @@ The RabbitMQ component supports 53 endpoint options which are listed below:
 // endpoint options: END
 
 
+
 See
 http://www.rabbitmq.com/releases/rabbitmq-java-client/current-javadoc/com/rabbitmq/client/ConnectionFactory.html[http://www.rabbitmq.com/releases/rabbitmq-java-client/current-javadoc/com/rabbitmq/client/ConnectionFactory.html]
 and the AMQP specification for more information on connection options.

http://git-wip-us.apache.org/repos/asf/camel/blob/ade42700/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQDeclareSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQDeclareSupport.java
b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQDeclareSupport.java
index 5b17370..7ccb6a6 100644
--- a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQDeclareSupport.java
+++ b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQDeclareSupport.java
@@ -87,12 +87,16 @@ public class RabbitMQDeclareSupport {
         return !endpoint.isSkipExchangeDeclare();
     }
 
+    private boolean shouldBindQueue(){
+      return !endpoint.isSkipQueueBind();
+    }
+    
     private void populateQueueArgumentsFromConfigurer(final Map<String, Object> queueArgs)
{
         if (endpoint.getQueueArgsConfigurer() != null) {
             endpoint.getQueueArgsConfigurer().configurArgs(queueArgs);
         }
     }
-
+    
     private void declareExchange(final Channel channel, final String exchange, final String
exchangeType, final Map<String, Object> exchangeArgs) throws IOException {
         channel.exchangeDeclare(exchange, exchangeType, endpoint.isDurable(), endpoint.isAutoDelete(),
exchangeArgs);
     }
@@ -100,7 +104,9 @@ public class RabbitMQDeclareSupport {
     private void declareAndBindQueue(final Channel channel, final String queue, final String
exchange, final String routingKey, final Map<String, Object> arguments)
             throws IOException {
         channel.queueDeclare(queue, endpoint.isDurable(), false, endpoint.isAutoDelete(),
arguments);
+       if(shouldBindQueue()){
         channel.queueBind(queue, exchange, emptyIfNull(routingKey));
+       }
     }
 
     private String emptyIfNull(final String routingKey) {

http://git-wip-us.apache.org/repos/asf/camel/blob/ade42700/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java
----------------------------------------------------------------------
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 53262f2..bf40766 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
@@ -81,6 +81,8 @@ public class RabbitMQEndpoint extends DefaultEndpoint implements AsyncEndpoint
{
     @UriParam(label = "common")
     private boolean skipQueueDeclare;
     @UriParam(label = "common")
+    private boolean skipQueueBind;
+    @UriParam(label = "common")
     private boolean skipExchangeDeclare;
     @UriParam(label = "advanced")
     private Address[] addresses;
@@ -406,7 +408,19 @@ public class RabbitMQEndpoint extends DefaultEndpoint implements AsyncEndpoint
{
     public boolean isSkipQueueDeclare() {
         return skipQueueDeclare;
     }
-    
+
+    /**
+     * If true the queue will not be bound to the exchange after declaring it
+     * @return 
+     */
+    public boolean isSkipQueueBind() {
+        return skipQueueBind;
+    }
+
+    public void setSkipQueueBind(boolean skipQueueBind) {
+        this.skipQueueBind = skipQueueBind;
+    }
+     
     /**
      * This can be used if we need to declare the queue but not the exchange
      */

http://git-wip-us.apache.org/repos/asf/camel/blob/ade42700/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointTest.java
b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointTest.java
index 291c907..e8c4267 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointTest.java
@@ -260,4 +260,10 @@ public class RabbitMQEndpointTest extends CamelTestSupport {
         RabbitMQEndpoint endpoint = context.getEndpoint("rabbitmq:localhost/exchange?skipExchangeDeclare=true",
RabbitMQEndpoint.class);
         assertTrue(endpoint.isSkipExchangeDeclare());
     }
+    
+    @Test
+    public void createEndpointWithSkipQueueBindEndabled() throws Exception {
+        RabbitMQEndpoint endpoint = context.getEndpoint("rabbitmq:localhost/exchange?SkipQueueBind=true",
RabbitMQEndpoint.class);
+        assertTrue(endpoint.isSkipQueueBind());
+    }
 }


Mime
View raw message