From 27a6f1c6ab25644e561fb9e2f20cd07ff4211209 Mon Sep 17 00:00:00 2001 From: Robert Davies Date: Mon, 18 Jan 2010 19:52:50 +0000 Subject: [PATCH] added logging for Timestamp plugin git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@900526 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/broker/BrokerPluginSupport.java | 17 ++++++++++++++++- .../broker/util/TimeStampingBrokerPlugin.java | 10 +++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/BrokerPluginSupport.java b/activemq-core/src/main/java/org/apache/activemq/broker/BrokerPluginSupport.java index fe3e1baed9..d2ff04efb5 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/BrokerPluginSupport.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/BrokerPluginSupport.java @@ -16,13 +16,16 @@ */ 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. * * @version $Revision$ */ public abstract class BrokerPluginSupport extends MutableBrokerFilter implements BrokerPlugin { - + private static final Log LOG = LogFactory.getLog(BrokerPluginSupport.class); public BrokerPluginSupport() { super(null); } @@ -32,4 +35,16 @@ public abstract class BrokerPluginSupport extends MutableBrokerFilter implements 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"); + } + } diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/util/TimeStampingBrokerPlugin.java b/activemq-core/src/main/java/org/apache/activemq/broker/util/TimeStampingBrokerPlugin.java index 803795b047..c3ee6d19d3 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/util/TimeStampingBrokerPlugin.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/util/TimeStampingBrokerPlugin.java @@ -45,7 +45,7 @@ import org.apache.commons.logging.LogFactory; * @version $Revision$ */ public class TimeStampingBrokerPlugin extends BrokerPluginSupport { - + private static final Log LOG = LogFactory.getLog(TimeStampingBrokerPlugin.class); /** * variable which (when non-zero) is used to override * the expiration date for messages that arrive with @@ -85,15 +85,16 @@ public class TimeStampingBrokerPlugin extends BrokerPluginSupport { 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 && (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(); long timeToLive = zeroExpirationOverride; + long oldTimestamp = message.getTimestamp(); if (oldExpiration > 0) { - long oldTimestamp = message.getTimestamp(); timeToLive = oldExpiration - oldTimestamp; } if (timeToLive > 0 && ttlCeiling > 0 && timeToLive > ttlCeiling) { @@ -106,6 +107,9 @@ public class TimeStampingBrokerPlugin extends BrokerPluginSupport { message.setExpiration(expiration); } message.setTimestamp(newTimeStamp); + if (LOG.isDebugEnabled()) { + LOG.debug("Set message " + message.getMessageId() + " timestamp from " + oldTimestamp + " to " + newTimeStamp); + } } } super.send(producerExchange, message);