git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@822295 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2009-10-06 14:39:27 +00:00
parent 869401136e
commit dd957fae8c
2 changed files with 19 additions and 6 deletions

View File

@ -59,6 +59,12 @@ public class TimeStampingBrokerPlugin extends BrokerPluginSupport {
*/
long ttlCeiling = 0;
/**
* If true, the plugin will not update timestamp to past values
* False by default
*/
boolean futureOnly = false;
/**
* setter method for zeroExpirationOverride
*/
@ -75,13 +81,16 @@ public class TimeStampingBrokerPlugin extends BrokerPluginSupport {
this.ttlCeiling = ttlCeiling;
}
public void setFutureOnly(boolean futureOnly) {
this.futureOnly = futureOnly;
}
public void send(ProducerBrokerExchange producerExchange, Message message) throws Exception {
if (message.getTimestamp() > 0
&& (message.getBrokerPath() == null || message.getBrokerPath().length == 0)) {
// timestamp not been disabled and has not passed through a network
long oldExpiration = message.getExpiration();
long newTimeStamp = System.currentTimeMillis();
message.setTimestamp(newTimeStamp);
long timeToLive = zeroExpirationOverride;
if (oldExpiration > 0) {
long oldTimestamp = message.getTimestamp();
@ -91,9 +100,13 @@ public class TimeStampingBrokerPlugin extends BrokerPluginSupport {
timeToLive = ttlCeiling;
}
long expiration = timeToLive + newTimeStamp;
//In the scenario that the Broker is behind the clients we never want to set the Timestamp and Expiration in the past
if(!futureOnly || (expiration > oldExpiration)) {
if (timeToLive > 0 && expiration > 0) {
message.setExpiration(expiration);
}
message.setTimestamp(newTimeStamp);
}
}
super.send(producerExchange, message);
}

View File

@ -28,7 +28,7 @@
<!-- lets enable detailed logging in the broker but ignore ConnectionEvents -->
<loggingBrokerPlugin logAll="true" logConnectionEvents="false"/>
<timeStampingBrokerPlugin zeroExpirationOverride="1000" ttlCeiling="60000"/>
<timeStampingBrokerPlugin zeroExpirationOverride="1000" ttlCeiling="60000" futureOnly="true"/>
<traceBrokerPathPlugin/>