mirror of
https://github.com/apache/activemq.git
synced 2025-02-16 23:16:52 +00:00
added logging for Timestamp plugin
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@900526 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2e98d40065
commit
27a6f1c6ab
@ -16,13 +16,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.activemq.broker;
|
package org.apache.activemq.broker;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A useful base class for implementing broker plugins.
|
* A useful base class for implementing broker plugins.
|
||||||
*
|
*
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
public abstract class BrokerPluginSupport extends MutableBrokerFilter implements BrokerPlugin {
|
public abstract class BrokerPluginSupport extends MutableBrokerFilter implements BrokerPlugin {
|
||||||
|
private static final Log LOG = LogFactory.getLog(BrokerPluginSupport.class);
|
||||||
public BrokerPluginSupport() {
|
public BrokerPluginSupport() {
|
||||||
super(null);
|
super(null);
|
||||||
}
|
}
|
||||||
@ -32,4 +35,16 @@ public abstract class BrokerPluginSupport extends MutableBrokerFilter implements
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() throws Exception {
|
||||||
|
super.start();
|
||||||
|
LOG.info("Broker Plugin " + getClass().getName() + " started");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() throws Exception {
|
||||||
|
super.stop();
|
||||||
|
LOG.info("Broker Plugin " + getClass().getName() + " stopped");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
public class TimeStampingBrokerPlugin extends BrokerPluginSupport {
|
public class TimeStampingBrokerPlugin extends BrokerPluginSupport {
|
||||||
|
private static final Log LOG = LogFactory.getLog(TimeStampingBrokerPlugin.class);
|
||||||
/**
|
/**
|
||||||
* variable which (when non-zero) is used to override
|
* variable which (when non-zero) is used to override
|
||||||
* the expiration date for messages that arrive with
|
* the expiration date for messages that arrive with
|
||||||
@ -85,15 +85,16 @@ public class TimeStampingBrokerPlugin extends BrokerPluginSupport {
|
|||||||
this.futureOnly = futureOnly;
|
this.futureOnly = futureOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(ProducerBrokerExchange producerExchange, Message message) throws Exception {
|
@Override
|
||||||
|
public void send(ProducerBrokerExchange producerExchange, Message message) throws Exception {
|
||||||
if (message.getTimestamp() > 0
|
if (message.getTimestamp() > 0
|
||||||
&& (message.getBrokerPath() == null || message.getBrokerPath().length == 0)) {
|
&& (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
|
||||||
long oldExpiration = message.getExpiration();
|
long oldExpiration = message.getExpiration();
|
||||||
long newTimeStamp = System.currentTimeMillis();
|
long newTimeStamp = System.currentTimeMillis();
|
||||||
long timeToLive = zeroExpirationOverride;
|
long timeToLive = zeroExpirationOverride;
|
||||||
|
long oldTimestamp = message.getTimestamp();
|
||||||
if (oldExpiration > 0) {
|
if (oldExpiration > 0) {
|
||||||
long oldTimestamp = message.getTimestamp();
|
|
||||||
timeToLive = oldExpiration - oldTimestamp;
|
timeToLive = oldExpiration - oldTimestamp;
|
||||||
}
|
}
|
||||||
if (timeToLive > 0 && ttlCeiling > 0 && timeToLive > ttlCeiling) {
|
if (timeToLive > 0 && ttlCeiling > 0 && timeToLive > ttlCeiling) {
|
||||||
@ -106,6 +107,9 @@ public class TimeStampingBrokerPlugin extends BrokerPluginSupport {
|
|||||||
message.setExpiration(expiration);
|
message.setExpiration(expiration);
|
||||||
}
|
}
|
||||||
message.setTimestamp(newTimeStamp);
|
message.setTimestamp(newTimeStamp);
|
||||||
|
if (LOG.isDebugEnabled()) {
|
||||||
|
LOG.debug("Set message " + message.getMessageId() + " timestamp from " + oldTimestamp + " to " + newTimeStamp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.send(producerExchange, message);
|
super.send(producerExchange, message);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user