mirror of https://github.com/apache/activemq.git
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:
parent
48522098f5
commit
26198c2094
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue