diff options
| author | Robert Gemmell <robbie@apache.org> | 2013-10-13 22:21:59 +0000 |
|---|---|---|
| committer | Robert Gemmell <robbie@apache.org> | 2013-10-13 22:21:59 +0000 |
| commit | 3b9b2ece8af8767492c77ea0e3bbd71a36307ce7 (patch) | |
| tree | 5e76fca495e60f54a6ca473d329ccdeabe0a73cd /qpid/java | |
| parent | fe16af8023970c2291d9023abbaf6f1b92befaf5 (diff) | |
| download | qpid-python-3b9b2ece8af8767492c77ea0e3bbd71a36307ce7.tar.gz | |
QPID-5223: add system property to toggle populating the 'expiration' header with the raw TTL value instead of the actual expiration time, for interop with e.g. RabbitMQ
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1531761 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
| -rw-r--r-- | qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java | 17 | ||||
| -rw-r--r-- | qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java | 7 |
2 files changed, 21 insertions, 3 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java index bb270b0878..3cb723e5a8 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java @@ -24,6 +24,7 @@ import org.apache.qpid.AMQException; import org.apache.qpid.client.message.AMQMessageDelegate_0_8; import org.apache.qpid.client.message.AbstractJMSMessage; import org.apache.qpid.client.protocol.AMQProtocolHandler; +import org.apache.qpid.configuration.ClientProperties; import org.apache.qpid.framing.AMQFrame; import org.apache.qpid.framing.BasicContentHeaderProperties; import org.apache.qpid.framing.BasicPublishBody; @@ -32,7 +33,6 @@ import org.apache.qpid.framing.ContentBody; import org.apache.qpid.framing.ContentHeaderBody; import org.apache.qpid.framing.ExchangeDeclareBody; import org.apache.qpid.framing.MethodRegistry; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,12 +40,14 @@ import javax.jms.JMSException; import javax.jms.Message; import javax.jms.Queue; import javax.jms.Topic; + import java.nio.ByteBuffer; import java.util.UUID; public class BasicMessageProducer_0_8 extends BasicMessageProducer { - private static final Logger _logger = LoggerFactory.getLogger(BasicMessageProducer_0_8.class); + private static final Logger _logger = LoggerFactory.getLogger(BasicMessageProducer_0_8.class); + private static final boolean SET_EXPIRATION_AS_TTL = Boolean.getBoolean(ClientProperties.SET_EXPIRATION_AS_TTL); BasicMessageProducer_0_8(AMQConnection connection, AMQDestination destination, boolean transacted, int channelId, AMQSession session, AMQProtocolHandler protocolHandler, long producerId, Boolean immediate, Boolean mandatory) throws AMQException @@ -118,7 +120,16 @@ public class BasicMessageProducer_0_8 extends BasicMessageProducer if (timeToLive > 0) { - contentHeaderProperties.setExpiration(currentTime + timeToLive); + if(!SET_EXPIRATION_AS_TTL) + { + //default behaviour used by Qpid + contentHeaderProperties.setExpiration(currentTime + timeToLive); + } + else + { + //alternative behaviour for brokers interpreting the expiration header directly as a TTL. + contentHeaderProperties.setExpiration(timeToLive); + } } else { diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java index a0140785f4..51dad51bf9 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java @@ -208,6 +208,13 @@ public class ClientProperties public static final String QPID_MAX_CACHED_ADDR_OPTION_STRINGS = "qpid.max_cached_address_option_strings"; public static final int DEFAULT_MAX_CACHED_ADDR_OPTION_STRINGS = 10; + /** + * System property to control whether the 0-8/0-9/0-9-1 client will set the message + * 'expiration' header using the computed expiration value (default, when false) or instead set + * it to the raw TTL (when true). May be necessary for interop with other vendors. + */ + public static final String SET_EXPIRATION_AS_TTL = "qpid.set_expiration_as_ttl"; + private ClientProperties() { //No instances |
