activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r822318 - in /activemq/branches/activemq-5.3/activemq-core/src: main/java/org/apache/activemq/broker/util/TimeStampingBrokerPlugin.java test/resources/org/apache/activemq/util/plugin-broker.xml
Date Tue, 06 Oct 2009 15:32:25 GMT
Author: dejanb
Date: Tue Oct  6 15:32:25 2009
New Revision: 822318

URL: http://svn.apache.org/viewvc?rev=822318&view=rev
Log:
merging 822295 - timestamp plugin fix

Modified:
    activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/util/TimeStampingBrokerPlugin.java
    activemq/branches/activemq-5.3/activemq-core/src/test/resources/org/apache/activemq/util/plugin-broker.xml

Modified: activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/util/TimeStampingBrokerPlugin.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/util/TimeStampingBrokerPlugin.java?rev=822318&r1=822317&r2=822318&view=diff
==============================================================================
--- activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/util/TimeStampingBrokerPlugin.java
(original)
+++ activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/util/TimeStampingBrokerPlugin.java
Tue Oct  6 15:32:25 2009
@@ -58,6 +58,12 @@
     * 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 @@
         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 @@
                 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);
     }

Modified: activemq/branches/activemq-5.3/activemq-core/src/test/resources/org/apache/activemq/util/plugin-broker.xml
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-core/src/test/resources/org/apache/activemq/util/plugin-broker.xml?rev=822318&r1=822317&r2=822318&view=diff
==============================================================================
--- activemq/branches/activemq-5.3/activemq-core/src/test/resources/org/apache/activemq/util/plugin-broker.xml
(original)
+++ activemq/branches/activemq-5.3/activemq-core/src/test/resources/org/apache/activemq/util/plugin-broker.xml
Tue Oct  6 15:32:25 2009
@@ -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/>
       



Mime
View raw message