Backported fix to AMQ-1165

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@511464 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2007-02-25 08:34:49 +00:00
parent 48522098f5
commit 26198c2094
2 changed files with 47 additions and 4 deletions

View File

@ -369,10 +369,6 @@ public class RegionBroker implements Broker {
public void send(ConnectionContext context, Message message) throws Exception {
long si = sequenceGenerator.getNextSequenceId();
message.getMessageId().setBrokerSequenceId(si);
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:

View File

@ -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);
}
}