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

@ -65,6 +65,13 @@ public class TimeStampingBrokerPlugin extends BrokerPluginSupport {
*/ */
boolean futureOnly = false; boolean futureOnly = false;
/**
* if true, update timestamp even if message has passed through a network
* default false
*/
boolean processNetworkMessages = false;
/** /**
* setter method for zeroExpirationOverride * setter method for zeroExpirationOverride
*/ */
@ -85,11 +92,15 @@ public class TimeStampingBrokerPlugin extends BrokerPluginSupport {
this.futureOnly = futureOnly; this.futureOnly = futureOnly;
} }
public void setProcessNetworkMessages(Boolean processNetworkMessages) {
this.processNetworkMessages = processNetworkMessages;
}
@Override @Override
public void send(ProducerBrokerExchange producerExchange, Message message) throws Exception { public void send(ProducerBrokerExchange producerExchange, Message message) throws Exception {
if (message.getTimestamp() > 0 if (message.getTimestamp() > 0
&& (message.getBrokerPath() == null || message.getBrokerPath().length == 0)) { && (processNetworkMessages || (message.getBrokerPath() == null || message.getBrokerPath().length == 0))) {
// timestamp not been disabled and has not passed through a network // timestamp not been disabled and has not passed through a network or processNetworkMessages=true
long oldExpiration = message.getExpiration(); long oldExpiration = message.getExpiration();
long newTimeStamp = System.currentTimeMillis(); long newTimeStamp = System.currentTimeMillis();
long timeToLive = zeroExpirationOverride; long timeToLive = zeroExpirationOverride;