activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r511463 - in /activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker: region/RegionBroker.java util/TimeStampingBrokerPlugin.java
Date Sun, 25 Feb 2007 08:29:04 GMT
Author: chirino
Date: Sun Feb 25 00:29:03 2007
New Revision: 511463

URL: http://svn.apache.org/viewvc?view=rev&rev=511463
Log:
Fix for AMQ-1165

Made the broker side timestamping 'feature' (which is a JMS spec bug) and optional broker
plugin that can be enabled if a user really wants to have the broker timestamping behaviour.


Added:
    activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/util/TimeStampingBrokerPlugin.java
Modified:
    activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java

Modified: activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java?view=diff&rev=511463&r1=511462&r2=511463
==============================================================================
--- activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
(original)
+++ activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
Sun Feb 25 00:29:03 2007
@@ -376,10 +376,6 @@
 
     public void send(ConnectionContext context,  Message message) throws Exception {
         message.getMessageId().setBrokerSequenceId(sequenceGenerator.getNextSequenceId());
-        if (message.getTimestamp() > 0 && (message.getBrokerPath() == null ||
message.getBrokerPath().length == 0)) { 
-            //timestamp not been disabled and has not passed through a network
-            message.setTimestamp(System.currentTimeMillis());
-        }
         ActiveMQDestination destination = message.getDestination();
         switch(destination.getDestinationType()) {
         case ActiveMQDestination.QUEUE_TYPE:

Added: activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/util/TimeStampingBrokerPlugin.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/util/TimeStampingBrokerPlugin.java?view=auto&rev=511463
==============================================================================
--- activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/util/TimeStampingBrokerPlugin.java
(added)
+++ activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/util/TimeStampingBrokerPlugin.java
Sun Feb 25 00:29:03 2007
@@ -0,0 +1,47 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.broker.util;
+
+import org.apache.activemq.broker.BrokerPluginSupport;
+import org.apache.activemq.broker.ConnectionContext;
+import org.apache.activemq.command.Message;
+
+
+/**
+ * A Broker interceptor which updates a JMS Client's timestamp on the message
+ * with a broker timestamp.  Useful when the clocks on client machines are known to
+ * not be correct and you can only trust the time set on the broker machines.
+ * 
+ * Enabling this plugin will break JMS compliance since the timestamp that the producer
+ * sees on the messages after as send() will be different from the timestamp the consumer
+ * will observe when he receives the message.  This plugin is not enabled in the default
+ * ActiveMQ configuration.
+ * 
+ * @org.apache.xbean.XBean element="timeStampingBrokerPlugin" 
+ * 
+ * @version $Revision$
+ */
+public class TimeStampingBrokerPlugin  extends BrokerPluginSupport {
+	public void send(ConnectionContext context, 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
+            message.setTimestamp(System.currentTimeMillis());
+        }
+		super.send(context, message);
+	}
+}



Mime
View raw message