camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] git commit: CAMEL-6909: Added exchangeType option to camel-rabbit. Thanks to Dmitry Buzdin for the patch.
Date Fri, 08 Nov 2013 14:41:10 GMT
Updated Branches:
  refs/heads/camel-2.12.x e771d52c5 -> 8228cfee9


CAMEL-6909: Added exchangeType option to camel-rabbit. Thanks to  Dmitry Buzdin for the patch.


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

Branch: refs/heads/camel-2.12.x
Commit: 6c133546532e7581baa85ee087dc17d2afc75322
Parents: e771d52
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Nov 8 15:29:05 2013 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Nov 8 15:29:19 2013 +0100

----------------------------------------------------------------------
 .../component/rabbitmq/RabbitMQConsumer.java    |  6 +++--
 .../component/rabbitmq/RabbitMQEndpoint.java    |  9 +++++++
 .../rabbitmq/RabbitMQComponentTest.java         | 27 +++++++++++++++++---
 3 files changed, 37 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6c133546/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConsumer.java
b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConsumer.java
index f2fa128..df3f698 100644
--- a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConsumer.java
+++ b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConsumer.java
@@ -55,8 +55,10 @@ public class RabbitMQConsumer extends DefaultConsumer {
         channel = conn.createChannel();
         log.debug("Using channel {}", channel);
 
-        channel.exchangeDeclare(endpoint.getExchangeName(), "direct",
-                endpoint.isDurable(), endpoint.isAutoDelete(),
+        channel.exchangeDeclare(endpoint.getExchangeName(),
+                endpoint.getExchangeType(),
+                endpoint.isDurable(),
+                endpoint.isAutoDelete(),
                 new HashMap<String, Object>());
 
         // need to make sure the queueDeclare is same with the exchange declare

http://git-wip-us.apache.org/repos/asf/camel/blob/6c133546/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 4423721..b008646 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
@@ -51,6 +51,7 @@ public class RabbitMQEndpoint extends DefaultEndpoint {
     private boolean durable = true;
     private String queue = String.valueOf(UUID.randomUUID().toString().hashCode());
     private String exchangeName;
+    private String exchangeType = "direct";
     private String routingKey;
     
     public RabbitMQEndpoint() {
@@ -214,6 +215,14 @@ public class RabbitMQEndpoint extends DefaultEndpoint {
         this.exchangeName = exchangeName;
     }
 
+    public String getExchangeType() {
+        return exchangeType;
+    }
+
+    public void setExchangeType(String exchangeType) {
+        this.exchangeType = exchangeType;
+    }
+
     public String getRoutingKey() {
         return routingKey;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/6c133546/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQComponentTest.java
b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQComponentTest.java
index 244bc29..454a26d 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQComponentTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQComponentTest.java
@@ -30,6 +30,18 @@ public class RabbitMQComponentTest {
     private CamelContext context = Mockito.mock(CamelContext.class);
 
     @Test
+    public void testDefaultProperties() throws Exception {
+        RabbitMQEndpoint endpoint = createEndpoint(new HashMap<String, Object>());
+
+        assertEquals(14, endpoint.getPortNumber());
+        assertEquals(10, endpoint.getThreadPoolSize());
+        assertEquals(true, endpoint.isAutoAck());
+        assertEquals(true, endpoint.isAutoDelete());
+        assertEquals(true, endpoint.isDurable());
+        assertEquals("direct", endpoint.getExchangeType());
+    }
+
+    @Test
     public void testPropertiesSet() throws Exception {
         Map<String, Object> params = new HashMap<String, Object>();
         params.put("username", "coldplay");
@@ -40,11 +52,10 @@ public class RabbitMQComponentTest {
         params.put("portNumber", 14123);
         params.put("hostname", "special.host");
         params.put("queue", "queuey");
+        params.put("exchangeType", "topic");
 
-        String uri = "rabbitmq:special.host:14/queuey";
-        String remaining = "special.host:14/queuey";
+        RabbitMQEndpoint endpoint = createEndpoint(params);
 
-        RabbitMQEndpoint endpoint = new RabbitMQComponent(context).createEndpoint(uri, remaining,
params);
         assertEquals("chrism", endpoint.getPassword());
         assertEquals("coldplay", endpoint.getUsername());
         assertEquals("queuey", endpoint.getQueue());
@@ -53,5 +64,15 @@ public class RabbitMQComponentTest {
         assertEquals(14123, endpoint.getPortNumber());
         assertEquals(515, endpoint.getThreadPoolSize());
         assertEquals(true, endpoint.isAutoAck());
+        assertEquals(true, endpoint.isAutoDelete());
+        assertEquals(true, endpoint.isDurable());
+        assertEquals("topic", endpoint.getExchangeType());
+    }
+
+    private RabbitMQEndpoint createEndpoint(Map<String, Object> params) throws Exception
{
+        String uri = "rabbitmq:special.host:14/queuey";
+        String remaining = "special.host:14/queuey";
+
+        return new RabbitMQComponent(context).createEndpoint(uri, remaining, params);
     }
 }


Mime
View raw message