From d4a39c33f6f0e3d88a385cdbf0eb942a60ceb781 Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Thu, 8 Jul 2010 18:20:33 +0000 Subject: 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 --- .../qpid/client/BasicMessageProducer_0_10.java | 24 +++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'java/client/src/main') 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 appProps = messageProps.getApplicationHeaders(); if (appProps == null) { appProps = new HashMap(); + 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 -- cgit v1.2.1