Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 38566 invoked from network); 25 Feb 2007 08:29:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Feb 2007 08:29:25 -0000 Received: (qmail 61545 invoked by uid 500); 25 Feb 2007 08:29:33 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 61521 invoked by uid 500); 25 Feb 2007 08:29:33 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 61512 invoked by uid 99); 25 Feb 2007 08:29:33 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Feb 2007 00:29:33 -0800 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Feb 2007 00:29:24 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 47DB21A981A; Sun, 25 Feb 2007 00:29:04 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@activemq.apache.org From: chirino@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070225082904.47DB21A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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); + } +}