diff options
author | Rajith Muditha Attapattu <rajith@apache.org> | 2010-07-08 18:20:33 +0000 |
---|---|---|
committer | Rajith Muditha Attapattu <rajith@apache.org> | 2010-07-08 18:20:33 +0000 |
commit | d4a39c33f6f0e3d88a385cdbf0eb942a60ceb781 (patch) | |
tree | bc035d5b5bc2a8fc8f595113b2004f75dfe67855 | |
parent | f231e17e6a2bfbe9c3ce46c878f77240c437eee5 (diff) | |
download | qpid-python-d4a39c33f6f0e3d88a385cdbf0eb942a60ceb781.tar.gz |
QPID-2722
The producer now checks for the presense of qpid.subject in the header and uses it as the routing-key if sending to an exchange.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@961862 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java index c01439792a..6b7525b796 100644 --- a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java +++ b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java @@ -168,17 +168,31 @@ public class BasicMessageProducer_0_10 extends BasicMessageProducer deliveryProp.setRoutingKey(routingKey); } - if (destination.getSubject() != null && !destination.getSubject().equals("")) + if (destination.getDestSyntax() == AMQDestination.DestSyntax.ADDR && + (destination.getSubject() != null || + (messageProps.getApplicationHeaders() != null && messageProps.getApplicationHeaders().get("qpid.subject") != null)) + ) { Map<String,Object> appProps = messageProps.getApplicationHeaders(); if (appProps == null) { appProps = new HashMap<String,Object>(); + messageProps.setApplicationHeaders(appProps); } - appProps.put("qpid.subject",destination.getSubject()); - messageProps.setApplicationHeaders(appProps); - } - + + if (appProps.get("qpid.subject") == null) + { + // use default subject in address string + appProps.put("qpid.subject",destination.getSubject()); + } + + if (destination.getTargetNode().getType() == AMQDestination.TOPIC_TYPE) + { + deliveryProp.setRoutingKey((String) + messageProps.getApplicationHeaders().get("qpid.subject")); + } + } + messageProps.setContentLength(message.getContentLength()); // send the message |