https://issues.apache.org/jira/browse/AMQ-3576 - fix regression in network connector tests, the sequence id check is not valud for bridges that concentrate messages from multiple consumers. duplicate suppression for network connectors needs to be based on message ids

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1197072 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2011-11-03 11:53:31 +00:00
parent 5cf33b52c1
commit 2711ad1f3f
2 changed files with 9 additions and 5 deletions

View File

@ -39,6 +39,7 @@ public class ProducerBrokerExchange {
private ProducerState producerState;
private boolean mutable = true;
private AtomicLong lastSendSequenceNumber = new AtomicLong(-1);
private boolean auditProducerSequenceIds;
public ProducerBrokerExchange() {
}
@ -131,20 +132,23 @@ public class ProducerBrokerExchange {
*/
public boolean canDispatch(Message messageSend) {
boolean canDispatch = true;
if (lastSendSequenceNumber.get() > 0) {
if (auditProducerSequenceIds) {
if (messageSend.getMessageId().getProducerSequenceId() <= lastSendSequenceNumber.get()) {
canDispatch = false;
LOG.debug("suppressing duplicate message send [" + messageSend.getMessageId() + "] with producerSequenceId ["
+ messageSend.getMessageId().getProducerSequenceId() + "] less than last stored: " + lastSendSequenceNumber);
}
}
if (canDispatch) {
lastSendSequenceNumber.set(messageSend.getMessageId().getProducerSequenceId());
if (canDispatch) {
// track current so we can suppress duplicates later in the stream
lastSendSequenceNumber.set(messageSend.getMessageId().getProducerSequenceId());
}
}
return canDispatch;
}
public void setLastStoredSequenceId(long l) {
auditProducerSequenceIds = true;
lastSendSequenceNumber.set(l);
LOG.debug("last stored sequence id set: " + l);
}

View File

@ -1313,7 +1313,7 @@ public class TransportConnection implements Connection, Task, CommandVisitor {
result = new ProducerBrokerExchange();
TransportConnectionState state = lookupConnectionState(id);
context = state.getContext();
if (context.isReconnect()) {
if (context.isReconnect() && !context.isNetworkConnection()) {
result.setLastStoredSequenceId(broker.getBrokerService().getPersistenceAdapter().getLastProducerSequenceId(id));
}
result.setConnectionContext(context);