https://issues.apache.org/jira/browse/AMQ-3576 - disable auditNetworkProducers by default, composite dests and virtual topics that create duplicates independent of producers are trapped in error, for simple networking this should be enabled

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1205930 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2011-11-24 17:02:35 +00:00
parent 6352502376
commit 49718ed8a6
6 changed files with 54 additions and 15 deletions

View File

@ -143,13 +143,17 @@ public class ProducerBrokerExchange {
long lastStoredForMessageProducer = getStoredSequenceIdForMessage(messageSend.getMessageId()); long lastStoredForMessageProducer = getStoredSequenceIdForMessage(messageSend.getMessageId());
if (producerSequenceId <= lastStoredForMessageProducer) { if (producerSequenceId <= lastStoredForMessageProducer) {
canDispatch = false; canDispatch = false;
LOG.debug("suppressing duplicate message send from network producer [" + messageSend.getMessageId() + "] with producerSequenceId [" if (LOG.isDebugEnabled()) {
+ producerSequenceId + "] less than last stored: " + lastStoredForMessageProducer); LOG.debug("suppressing duplicate message send [" + (LOG.isTraceEnabled() ? messageSend : messageSend.getMessageId()) + "] from network producer with producerSequenceId ["
+ producerSequenceId + "] less than last stored: " + lastStoredForMessageProducer);
}
} }
} else if (producerSequenceId <= lastSendSequenceNumber.get()) { } else if (producerSequenceId <= lastSendSequenceNumber.get()) {
canDispatch = false; canDispatch = false;
LOG.debug("suppressing duplicate message send [" + messageSend.getMessageId() + "] with producerSequenceId [" if (LOG.isDebugEnabled()) {
+ producerSequenceId + "] less than last stored: " + lastSendSequenceNumber); LOG.debug("suppressing duplicate message send [" + (LOG.isTraceEnabled() ? messageSend : messageSend.getMessageId()) + "] with producerSequenceId ["
+ producerSequenceId + "] less than last stored: " + lastSendSequenceNumber);
}
} else { } else {
// track current so we can suppress duplicates later in the stream // track current so we can suppress duplicates later in the stream
lastSendSequenceNumber.set(producerSequenceId); lastSendSequenceNumber.set(producerSequenceId);

View File

@ -71,7 +71,7 @@ public class TransportConnector implements Connector, BrokerServiceAware {
private boolean rebalanceClusterClients; private boolean rebalanceClusterClients;
private boolean updateClusterClientsOnRemove = false; private boolean updateClusterClientsOnRemove = false;
private String updateClusterFilter; private String updateClusterFilter;
private boolean auditNetworkProducers = true; private boolean auditNetworkProducers = false;
public TransportConnector() { public TransportConnector() {
} }
@ -117,6 +117,7 @@ public class TransportConnector implements Connector, BrokerServiceAware {
rc.setRebalanceClusterClients(isRebalanceClusterClients()); rc.setRebalanceClusterClients(isRebalanceClusterClients());
rc.setUpdateClusterFilter(getUpdateClusterFilter()); rc.setUpdateClusterFilter(getUpdateClusterFilter());
rc.setUpdateClusterClientsOnRemove(isUpdateClusterClientsOnRemove()); rc.setUpdateClusterClientsOnRemove(isUpdateClusterClientsOnRemove());
rc.setAuditNetworkProducers(isAuditNetworkProducers());
return rc; return rc;
} }
@ -563,6 +564,11 @@ public class TransportConnector implements Connector, BrokerServiceAware {
return auditNetworkProducers; return auditNetworkProducers;
} }
/**
* Enable a producer audit on network connections, Traps the case of a missing send reply and resend.
* Note: does not work with conduit=false, networked composite destinations or networked virtual topics
* @param auditNetworkProducers
*/
public void setAuditNetworkProducers(boolean auditNetworkProducers) { public void setAuditNetworkProducers(boolean auditNetworkProducers) {
this.auditNetworkProducers = auditNetworkProducers; this.auditNetworkProducers = auditNetworkProducers;
} }

View File

@ -643,7 +643,7 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
Message message = configureMessage(md); Message message = configureMessage(md);
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("bridging (" + configuration.getBrokerName() + " -> " + remoteBrokerName + ") " + message.getMessageId() + ", consumer: " + md.getConsumerId() + ", destination " + message.getDestination() + ", brokerPath: " + Arrays.toString(message.getBrokerPath()) + ", message: " + message); LOG.debug("bridging (" + configuration.getBrokerName() + " -> " + remoteBrokerName + ") " + (LOG.isTraceEnabled() ? message : message.getMessageId()) + ", consumer: " + md.getConsumerId() + ", destination " + message.getDestination() + ", brokerPath: " + Arrays.toString(message.getBrokerPath()) + ", message: " + message);
} }
if (!configuration.isAlwaysSyncSend() && !message.isPersistent()) { if (!configuration.isAlwaysSyncSend() && !message.isPersistent()) {

View File

@ -177,7 +177,7 @@ public class JmsMultipleBrokersTestSupport extends CombinationTestSupport {
int activeCount = 0; int activeCount = 0;
for (NetworkBridge bridge : broker.getNetworkConnectors().get(bridgeIndex).activeBridges()) { for (NetworkBridge bridge : broker.getNetworkConnectors().get(bridgeIndex).activeBridges()) {
if (bridge.getRemoteBrokerName() != null) { if (bridge.getRemoteBrokerName() != null) {
LOG.info("found bridge to " + bridge.getRemoteBrokerName() + " on broker :" + broker.getBrokerName()); LOG.info("found bridge[" + bridge + "] to " + bridge.getRemoteBrokerName() + " on broker :" + broker.getBrokerName());
activeCount++; activeCount++;
} }
} }

View File

@ -25,11 +25,13 @@ import javax.jms.MessageConsumer;
import javax.jms.QueueBrowser; import javax.jms.QueueBrowser;
import org.apache.activemq.JmsMultipleBrokersTestSupport; import org.apache.activemq.JmsMultipleBrokersTestSupport;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.region.QueueSubscription; import org.apache.activemq.broker.region.QueueSubscription;
import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQTextMessage; import org.apache.activemq.command.ActiveMQTextMessage;
import org.apache.activemq.network.NetworkConnector; import org.apache.activemq.network.NetworkConnector;
import org.apache.activemq.util.MessageIdList; import org.apache.activemq.util.MessageIdList;
import org.apache.activemq.util.Wait;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
@ -97,18 +99,20 @@ public class BrowseOverNetworkTest extends JmsMultipleBrokersTestSupport {
String broker; String broker;
Destination dest; Destination dest;
int totalCount; int totalCount;
final int expect;
QueueBrowser browser = null; QueueBrowser browser = null;
MessageConsumer consumer = null; MessageConsumer consumer = null;
boolean consume = false; boolean consume = false;
public Browser(String broker, Destination dest) { public Browser(String broker, Destination dest, int expect) {
this.broker = broker; this.broker = broker;
this.dest = dest; this.dest = dest;
this.expect = expect;
} }
public void run() { public void run() {
int retries = 0; int retries = 0;
while (retries++ < 5) { while (retries++ < 20 && totalCount != expect) {
try { try {
QueueBrowser browser = createBrowser(broker, dest); QueueBrowser browser = createBrowser(broker, dest);
int count = browseMessages(browser, broker); int count = browseMessages(browser, broker);
@ -172,19 +176,39 @@ public class BrowseOverNetworkTest extends JmsMultipleBrokersTestSupport {
brokers.get("broker-2A").broker.waitUntilStarted(); brokers.get("broker-2A").broker.waitUntilStarted();
brokers.get("broker-3A").broker.waitUntilStarted(); brokers.get("broker-3A").broker.waitUntilStarted();
for (BrokerItem brokerItem : brokers.values()) {
final BrokerService broker = brokerItem.broker;
waitForBridgeFormation(broker, 1, 0);
waitForBridgeFormation(broker, 1, 1);
waitForBridgeFormation(broker, 1, 2);
waitForBridgeFormation(broker, 1, 3);
waitForBridgeFormation(broker, 1, 4);
}
Destination composite = createDestination("PROD.FUSESOURCE.3.A,PROD.FUSESOURCE.3.B", false); Destination composite = createDestination("PROD.FUSESOURCE.3.A,PROD.FUSESOURCE.3.B", false);
Browser browser1 = new Browser("broker-3A", composite); final Browser browser1 = new Browser("broker-3A", composite, MESSAGE_COUNT);
browser1.start(); browser1.start();
Thread.sleep(1000); final Browser browser2 = new Browser("broker-3B", composite, MESSAGE_COUNT);
Browser browser2 = new Browser("broker-3B", composite);
browser2.start(); browser2.start();
Thread.sleep(1000); LOG.info("Sending messages to broker-1A");
sendMessages("broker-1A", composite, MESSAGE_COUNT); sendMessages("broker-1A", composite, MESSAGE_COUNT);
LOG.info("Message sent to broker-1A");
Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return browser1.getTotalCount() == MESSAGE_COUNT;
}
});
Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return browser2.getTotalCount() == MESSAGE_COUNT;
}
});
browser1.join(); browser1.join();
browser2.join(); browser2.join();

View File

@ -369,6 +369,9 @@ public class TwoBrokerQueueClientsReconnectTest extends JmsMultipleBrokersTestSu
broker1 = "BrokerA"; broker1 = "BrokerA";
broker2 = "BrokerB"; broker2 = "BrokerB";
// enable producer audit for the network connector, off by default b/c of interference with composite
// dests and virtual topics
brokers.get(broker2).broker.getTransportConnectors().get(0).setAuditNetworkProducers(true);
bridgeBrokers(broker1, broker2); bridgeBrokers(broker1, broker2);
final AtomicBoolean first = new AtomicBoolean(); final AtomicBoolean first = new AtomicBoolean();
@ -406,6 +409,8 @@ public class TwoBrokerQueueClientsReconnectTest extends JmsMultipleBrokersTestSu
// Run brokers // Run brokers
startAllBrokers(); startAllBrokers();
waitForBridgeFormation();
// Create queue // Create queue
Destination dest = createDestination("TEST.FOO", false); Destination dest = createDestination("TEST.FOO", false);