mirror of https://github.com/apache/activemq.git
https://issues.apache.org/activemq/browse/AMQ-2441 - timestampbroker fix
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@822295 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
869401136e
commit
dd957fae8c
|
@ -58,6 +58,12 @@ public class TimeStampingBrokerPlugin extends BrokerPluginSupport {
|
|||
* the expiration date (in Milliseconds).
|
||||
*/
|
||||
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 send(ProducerBrokerExchange producerExchange, Message message) throws Exception {
|
||||
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;
|
||||
if (timeToLive > 0 && expiration > 0) {
|
||||
message.setExpiration(expiration);
|
||||
}
|
||||
//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);
|
||||
}
|
||||
|
|
|
@ -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/>
|
||||
|
||||
|
|
Loading…
Reference in New Issue