From 4ef1fc74cf8068b5c41cc1f4d1c97967658a465b Mon Sep 17 00:00:00 2001 From: gtully Date: Thu, 30 Mar 2017 12:12:13 +0100 Subject: [PATCH] [AMQ-6640] either broker dispatch to bridge or bridge dispatch to broker needs to be async - dispatchAsync network option is the trigger for the vm transport to be sync in line with the current defaults. original BacklogNetworkCrossTalkTest scenario exposed this. upshot is dispatchAsync=false is not compatible with duplicate subscription suppression which is fair. --- .../java/org/apache/activemq/broker/TransportConnection.java | 2 +- .../org/apache/activemq/network/NetworkBridgeFactory.java | 5 +++-- .../java/org/apache/activemq/network/NetworkConnector.java | 2 +- .../activemq/usecases/BacklogNetworkCrossTalkTest.java | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java b/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java index 69d29bc39f..a444d27563 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java @@ -1428,7 +1428,7 @@ public class TransportConnection implements Connection, Task, CommandVisitor { } setDuplexNetworkConnectorId(duplexNetworkConnectorId); } - Transport localTransport = NetworkBridgeFactory.createLocalTransport(broker.getVmConnectorURI()); + Transport localTransport = NetworkBridgeFactory.createLocalTransport(config, broker.getVmConnectorURI()); Transport remoteBridgeTransport = transport; if (! (remoteBridgeTransport instanceof ResponseCorrelator)) { // the vm transport case is already wrapped diff --git a/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridgeFactory.java b/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridgeFactory.java index 32711a4586..32a78537ac 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridgeFactory.java +++ b/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridgeFactory.java @@ -58,8 +58,9 @@ public final class NetworkBridgeFactory { return result; } - public static Transport createLocalTransport(URI uri) throws Exception { - return createLocalTransport(uri, false); + public static Transport createLocalTransport(NetworkBridgeConfiguration configuration, URI uri) throws Exception { + // one end of the localbroker<->bridge transport needs to be async to allow concurrent forwards and acks + return createLocalTransport(uri, !configuration.isDispatchAsync()); } public static Transport createLocalAsyncTransport(URI uri) throws Exception { diff --git a/activemq-broker/src/main/java/org/apache/activemq/network/NetworkConnector.java b/activemq-broker/src/main/java/org/apache/activemq/network/NetworkConnector.java index f943b82cb9..62192d37a9 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/network/NetworkConnector.java +++ b/activemq-broker/src/main/java/org/apache/activemq/network/NetworkConnector.java @@ -140,7 +140,7 @@ public abstract class NetworkConnector extends NetworkBridgeConfiguration implem } protected Transport createLocalTransport() throws Exception { - return NetworkBridgeFactory.createLocalTransport(localURI); + return NetworkBridgeFactory.createLocalTransport(this, localURI); } public static ActiveMQDestination[] getDurableTopicDestinations(final Set durableDestinations) { diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/BacklogNetworkCrossTalkTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/BacklogNetworkCrossTalkTest.java index 6538af7f82..d1a66930aa 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/BacklogNetworkCrossTalkTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/BacklogNetworkCrossTalkTest.java @@ -52,7 +52,7 @@ public class BacklogNetworkCrossTalkTest extends JmsMultipleBrokersTestSupport { waitForBridgeFormation(); - final int numMessages = 2000; + final int numMessages = 1000; // Create queue ActiveMQDestination destA = createDestination("AAA", false); sendMessages("A", destA, numMessages); @@ -88,7 +88,7 @@ public class BacklogNetworkCrossTalkTest extends JmsMultipleBrokersTestSupport { @Override public void setUp() throws Exception { - messageSize = 500; + messageSize = 5000; super.setMaxTestTime(10*60*1000); super.setAutoFail(true); super.setUp();