resolve https://issues.apache.org/activemq/browse/AMQ-2752 - allow timestamp broker plugin to optinally modify network messages, processNetworkMessages attribute

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@948858 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2010-05-27 15:22:43 +00:00
parent ae7df9fcaa
commit b50ede668d
1 changed files with 13 additions and 2 deletions

View File

@ -64,6 +64,13 @@ public class TimeStampingBrokerPlugin extends BrokerPluginSupport {
* False by default
*/
boolean futureOnly = false;
/**
* if true, update timestamp even if message has passed through a network
* default false
*/
boolean processNetworkMessages = false;
/**
* setter method for zeroExpirationOverride
@ -84,12 +91,16 @@ public class TimeStampingBrokerPlugin extends BrokerPluginSupport {
public void setFutureOnly(boolean futureOnly) {
this.futureOnly = futureOnly;
}
public void setProcessNetworkMessages(Boolean processNetworkMessages) {
this.processNetworkMessages = processNetworkMessages;
}
@Override
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
&& (processNetworkMessages || (message.getBrokerPath() == null || message.getBrokerPath().length == 0))) {
// timestamp not been disabled and has not passed through a network or processNetworkMessages=true
long oldExpiration = message.getExpiration();
long newTimeStamp = System.currentTimeMillis();
long timeToLive = zeroExpirationOverride;