camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject git commit: CAMEL-7031 Let RabbitMQ producer use the default exchange
Date Tue, 03 Dec 2013 02:42:56 GMT
Updated Branches:
  refs/heads/master f7beff794 -> 4f7ffe9ad


CAMEL-7031 Let RabbitMQ producer use the default exchange


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

Branch: refs/heads/master
Commit: 4f7ffe9ad780a4eac86eb6cb7c10922814a2d885
Parents: f7beff7
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Tue Dec 3 10:42:17 2013 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Tue Dec 3 10:42:31 2013 +0800

----------------------------------------------------------------------
 .../camel/component/rabbitmq/RabbitMQProducer.java       | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4f7ffe9a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQProducer.java
b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQProducer.java
index 3331a7d..9e22886 100644
--- a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQProducer.java
+++ b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQProducer.java
@@ -84,15 +84,14 @@ public class RabbitMQProducer extends DefaultProducer {
         if (exchangeName == null || getEndpoint().isBridgeEndpoint()) {
             exchangeName = getEndpoint().getExchangeName();
         }
-        if (ObjectHelper.isEmpty(exchangeName)) {
-            throw new IllegalArgumentException("ExchangeName is not provided in the endpoint:
" + getEndpoint());
-        }
-
-        String key = exchange.getIn().getHeader(RabbitMQConstants.ROUTING_KEY, "", String.class);
+        String key = exchange.getIn().getHeader(RabbitMQConstants.ROUTING_KEY, null, String.class);
         // we just need to make sure RoutingKey option take effect
-        if (key.trim().length() == 0) {
+        if (key == null) {
             key = getEndpoint().getRoutingKey() == null ? "" : getEndpoint().getRoutingKey();
         }
+        if (ObjectHelper.isEmpty(key) && ObjectHelper.isEmpty(exchangeName)) {
+            throw new IllegalArgumentException("ExchangeName and RoutingKey is not provided
in the endpoint: " + getEndpoint());
+        }
         byte[] messageBodyBytes = exchange.getIn().getMandatoryBody(byte[].class);
         AMQP.BasicProperties.Builder properties = buildProperties(exchange);
 


Mime
View raw message