You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jb...@apache.org on 2022/02/26 21:16:23 UTC
[activemq-artemis] branch main updated (d5b6bfb -> 82e82cf)
This is an automated email from the ASF dual-hosted git repository.
jbertram pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git.
from d5b6bfb This closes #3930
new c51fda0 ARTEMIS-3685 support reloading bridges
new bc65438 ARTEMIS-3687 bridges with concurrency > 1 can leak
new 82e82cf This closes #3957
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../artemis/core/config/BridgeConfiguration.java | 28 ++++
.../core/management/impl/BridgeControlImpl.java | 35 +++--
.../artemis/core/server/ActiveMQServerLogger.java | 12 +-
.../artemis/core/server/cluster/Bridge.java | 3 +
.../core/server/cluster/ClusterManager.java | 35 +++--
.../core/server/cluster/impl/BridgeImpl.java | 142 +++++++--------------
.../cluster/impl/ClusterConnectionBridge.java | 18 ++-
.../core/server/impl/ActiveMQServerImpl.java | 23 +++-
.../core/server/management/ManagementService.java | 3 +-
.../management/impl/ManagementServiceImpl.java | 14 +-
.../server/group/impl/ClusteredResetMockTest.java | 3 +-
docs/user-manual/en/config-reload.md | 3 +-
docs/user-manual/en/core-bridges.md | 20 ++-
.../integration/cluster/bridge/BridgeTest.java | 36 ++++++
.../tests/integration/jms/RedeployTest.java | 77 +++++++++++
...ilter-updated.xml => reload-bridge-updated.xml} | 42 +++++-
...-queue-filter-updated.xml => reload-bridge.xml} | 42 +++++-
17 files changed, 363 insertions(+), 173 deletions(-)
copy tests/integration-tests/src/test/resources/{reload-queue-filter-updated.xml => reload-bridge-updated.xml} (55%)
copy tests/integration-tests/src/test/resources/{reload-queue-filter-updated.xml => reload-bridge.xml} (55%)
[activemq-artemis] 03/03: This closes #3957
Posted by jb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jbertram pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit 82e82cf323083948e0ab5dec434f9bdd88adca42
Merge: d5b6bfb bc65438
Author: Justin Bertram <jb...@apache.org>
AuthorDate: Sat Feb 26 15:16:04 2022 -0600
This closes #3957
.../artemis/core/config/BridgeConfiguration.java | 28 ++++
.../core/management/impl/BridgeControlImpl.java | 35 +++--
.../artemis/core/server/ActiveMQServerLogger.java | 12 +-
.../artemis/core/server/cluster/Bridge.java | 3 +
.../core/server/cluster/ClusterManager.java | 35 +++--
.../core/server/cluster/impl/BridgeImpl.java | 142 +++++++--------------
.../cluster/impl/ClusterConnectionBridge.java | 18 ++-
.../core/server/impl/ActiveMQServerImpl.java | 23 +++-
.../core/server/management/ManagementService.java | 3 +-
.../management/impl/ManagementServiceImpl.java | 14 +-
.../server/group/impl/ClusteredResetMockTest.java | 3 +-
docs/user-manual/en/config-reload.md | 3 +-
docs/user-manual/en/core-bridges.md | 20 ++-
.../integration/cluster/bridge/BridgeTest.java | 36 ++++++
.../tests/integration/jms/RedeployTest.java | 77 +++++++++++
.../src/test/resources/reload-bridge-updated.xml | 78 +++++++++++
.../src/test/resources/reload-bridge.xml | 78 +++++++++++
17 files changed, 443 insertions(+), 165 deletions(-)
[activemq-artemis] 02/03: ARTEMIS-3687 bridges with concurrency > 1 can leak
Posted by jb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jbertram pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit bc65438344caaecb82ad2d06b375519a0f5ef28e
Author: Justin Bertram <jb...@apache.org>
AuthorDate: Wed Feb 16 17:06:58 2022 -0600
ARTEMIS-3687 bridges with concurrency > 1 can leak
---
.../core/management/impl/BridgeControlImpl.java | 35 +++++++++------------
.../core/server/cluster/ClusterManager.java | 23 +++++++++-----
.../core/server/management/ManagementService.java | 3 +-
.../management/impl/ManagementServiceImpl.java | 14 ++++-----
.../server/group/impl/ClusteredResetMockTest.java | 3 +-
docs/user-manual/en/core-bridges.md | 20 +++++++-----
.../integration/cluster/bridge/BridgeTest.java | 36 ++++++++++++++++++++++
7 files changed, 88 insertions(+), 46 deletions(-)
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BridgeControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BridgeControlImpl.java
index 2bace39..dd431a9 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BridgeControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BridgeControlImpl.java
@@ -24,7 +24,6 @@ import javax.management.MBeanOperationInfo;
import org.apache.activemq.artemis.api.core.JsonUtil;
import org.apache.activemq.artemis.api.core.management.BridgeControl;
-import org.apache.activemq.artemis.core.config.BridgeConfiguration;
import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.core.server.cluster.Bridge;
import org.apache.activemq.artemis.logs.AuditLogger;
@@ -34,15 +33,11 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
private final Bridge bridge;
- private final BridgeConfiguration configuration;
-
public BridgeControlImpl(final Bridge bridge,
- final StorageManager storageManager,
- final BridgeConfiguration configuration) throws Exception {
+ final StorageManager storageManager) throws Exception {
super(BridgeControl.class, storageManager);
this.bridge = bridge;
- this.configuration = configuration;
}
// BridgeControlMBean implementation ---------------------------
@@ -54,7 +49,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
}
clearIO();
try {
- List<String> staticConnectors = configuration.getStaticConnectors();
+ List<String> staticConnectors = bridge.getConfiguration().getStaticConnectors();
return staticConnectors.toArray(new String[staticConnectors.size()]);
} finally {
blockOnIO();
@@ -68,7 +63,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
}
clearIO();
try {
- return configuration.getForwardingAddress();
+ return bridge.getConfiguration().getForwardingAddress();
} finally {
blockOnIO();
}
@@ -81,7 +76,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
}
clearIO();
try {
- return configuration.getQueueName();
+ return bridge.getConfiguration().getQueueName();
} finally {
blockOnIO();
}
@@ -94,7 +89,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
}
clearIO();
try {
- return configuration.getDiscoveryGroupName();
+ return bridge.getConfiguration().getDiscoveryGroupName();
} finally {
blockOnIO();
}
@@ -107,7 +102,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
}
clearIO();
try {
- return configuration.getFilterString();
+ return bridge.getConfiguration().getFilterString();
} finally {
blockOnIO();
}
@@ -120,7 +115,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
}
clearIO();
try {
- return configuration.getReconnectAttempts();
+ return bridge.getConfiguration().getReconnectAttempts();
} finally {
blockOnIO();
}
@@ -133,7 +128,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
}
clearIO();
try {
- return configuration.getName();
+ return bridge.getConfiguration().getName();
} finally {
blockOnIO();
}
@@ -146,7 +141,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
}
clearIO();
try {
- return configuration.getRetryInterval();
+ return bridge.getConfiguration().getRetryInterval();
} finally {
blockOnIO();
}
@@ -159,7 +154,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
}
clearIO();
try {
- return configuration.getRetryIntervalMultiplier();
+ return bridge.getConfiguration().getRetryIntervalMultiplier();
} finally {
blockOnIO();
}
@@ -172,7 +167,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
}
clearIO();
try {
- return configuration.getMaxRetryInterval();
+ return bridge.getConfiguration().getMaxRetryInterval();
} finally {
blockOnIO();
}
@@ -185,7 +180,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
}
clearIO();
try {
- return configuration.getTransformerConfiguration() == null ? null : configuration.getTransformerConfiguration().getClassName();
+ return bridge.getConfiguration().getTransformerConfiguration() == null ? null : bridge.getConfiguration().getTransformerConfiguration().getClassName();
} finally {
blockOnIO();
}
@@ -206,7 +201,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
}
clearIO();
try {
- return configuration.getTransformerConfiguration() == null ? null : configuration.getTransformerConfiguration().getProperties();
+ return bridge.getConfiguration().getTransformerConfiguration() == null ? null : bridge.getConfiguration().getTransformerConfiguration().getProperties();
} finally {
blockOnIO();
}
@@ -232,7 +227,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
}
clearIO();
try {
- return configuration.isUseDuplicateDetection();
+ return bridge.getConfiguration().isUseDuplicateDetection();
} finally {
blockOnIO();
}
@@ -245,7 +240,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
}
clearIO();
try {
- return configuration.isHA();
+ return bridge.getConfiguration().isHA();
} finally {
blockOnIO();
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterManager.java
index 406ddd4..fcaaf2f 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterManager.java
@@ -23,6 +23,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executor;
@@ -480,7 +481,7 @@ public class ClusterManager implements ActiveMQComponent {
String name = config.getConcurrency() > 1 ? (config.getName() + "-" + i) : config.getName();
Bridge bridge = new BridgeImpl(serverLocator, new BridgeConfiguration(config).setName(name), nodeManager.getUUID(), queue, executorFactory.getExecutor(), scheduledExecutor, server);
bridges.put(name, bridge);
- managementService.registerBridge(bridge, config);
+ managementService.registerBridge(bridge);
bridge.start();
if (server.hasBrokerBridgePlugins()) {
@@ -529,16 +530,24 @@ public class ClusterManager implements ActiveMQComponent {
}
public void destroyBridge(final String name) throws Exception {
- Bridge bridge;
+ List<Bridge> bridgesToRemove = new ArrayList<>();
synchronized (this) {
- bridge = bridges.remove(name);
- if (bridge != null) {
- bridge.stop();
- managementService.unregisterBridge(name);
+ for (Bridge bridge : bridges.values()) {
+ if (bridge.getName().toString().matches(name + "|" + name + "-\\d+")) {
+ bridge = bridges.get(bridge.getName().toString());
+ if (bridge != null) {
+ bridgesToRemove.add(bridge);
+ }
+ }
+ }
+ for (Bridge bridgeToRemove : bridgesToRemove) {
+ bridges.remove(bridgeToRemove.getName().toString());
+ bridgeToRemove.stop();
+ managementService.unregisterBridge(bridgeToRemove.getName().toString());
}
}
- if (bridge != null) {
+ for (Bridge bridge : bridgesToRemove) {
bridge.flushExecutor();
}
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementService.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementService.java
index a3bbe62..ac9b492 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementService.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementService.java
@@ -28,7 +28,6 @@ import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.api.core.management.AddressControl;
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
-import org.apache.activemq.artemis.core.config.BridgeConfiguration;
import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.management.impl.ActiveMQServerControlImpl;
@@ -120,7 +119,7 @@ public interface ManagementService extends NotificationService, ActiveMQComponen
//void unregisterDiscoveryGroup(String name) throws Exception;
- void registerBridge(Bridge bridge, BridgeConfiguration configuration) throws Exception;
+ void registerBridge(Bridge bridge) throws Exception;
void unregisterBridge(String name) throws Exception;
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
index c465b37..d99ac0d 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
@@ -16,8 +16,6 @@
*/
package org.apache.activemq.artemis.core.server.management.impl;
-import static org.apache.activemq.artemis.api.core.FilterConstants.NATIVE_MESSAGE_ID;
-
import javax.management.InstanceNotFoundException;
import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
@@ -57,7 +55,6 @@ import org.apache.activemq.artemis.api.core.management.ManagementHelper;
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
import org.apache.activemq.artemis.api.core.management.QueueControl;
import org.apache.activemq.artemis.api.core.management.ResourceNames;
-import org.apache.activemq.artemis.core.config.BridgeConfiguration;
import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.management.impl.AcceptorControlImpl;
@@ -111,6 +108,8 @@ import org.apache.activemq.artemis.utils.collections.ConcurrentHashSet;
import org.apache.activemq.artemis.utils.collections.TypedProperties;
import org.jboss.logging.Logger;
+import static org.apache.activemq.artemis.api.core.FilterConstants.NATIVE_MESSAGE_ID;
+
public class ManagementServiceImpl implements ManagementService {
private static final Logger logger = Logger.getLogger(ManagementServiceImpl.class);
@@ -455,13 +454,12 @@ public class ManagementServiceImpl implements ManagementService {
}
@Override
- public synchronized void registerBridge(final Bridge bridge,
- final BridgeConfiguration configuration) throws Exception {
+ public synchronized void registerBridge(final Bridge bridge) throws Exception {
bridge.setNotificationService(this);
- ObjectName objectName = objectNameBuilder.getBridgeObjectName(configuration.getName());
- BridgeControl control = new BridgeControlImpl(bridge, storageManager, configuration);
+ ObjectName objectName = objectNameBuilder.getBridgeObjectName(bridge.getName().toString());
+ BridgeControl control = new BridgeControlImpl(bridge, storageManager);
registerInJMX(objectName, control);
- registerInRegistry(ResourceNames.BRIDGE + configuration.getName(), control);
+ registerInRegistry(ResourceNames.BRIDGE + bridge.getName(), control);
}
@Override
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java
index 1234a08..2df3f61 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java
@@ -31,7 +31,6 @@ import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.api.core.management.AddressControl;
import org.apache.activemq.artemis.api.core.management.ManagementHelper;
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
-import org.apache.activemq.artemis.core.config.BridgeConfiguration;
import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.management.impl.ActiveMQServerControlImpl;
@@ -306,7 +305,7 @@ public class ClusteredResetMockTest extends ActiveMQTestBase {
}
@Override
- public void registerBridge(Bridge bridge, BridgeConfiguration configuration) throws Exception {
+ public void registerBridge(Bridge bridge) throws Exception {
}
diff --git a/docs/user-manual/en/core-bridges.md b/docs/user-manual/en/core-bridges.md
index 98b13f5..968b310 100644
--- a/docs/user-manual/en/core-bridges.md
+++ b/docs/user-manual/en/core-bridges.md
@@ -186,13 +186,19 @@ Let's take a look at all the parameters in turn:
flexibility to deal with any situation. Valid values are `ANYCAST`,
`MULTICAST`, `PASS`, & `STRIP`. The default is `PASS`.
-- `concurrency`. For bridging high latency networks, and particularly for destinations
- with a high throughput, more workers might have to be commited to the bridge. This is
- done with the concurrency parameter. Increasing the concurrency will get reflected
- by more consumers and producers showing up on the bridged destination, allowing
- for increased parallelism across high latency networks.
-
- Default=1
+- `concurrency`. For bridging high latency networks, and particularly for
+ destinations with a high throughput, more workers might have to be commited
+ to the bridge. This is done with the `concurrency` parameter. Increasing the
+ concurrency will get reflected by more consumers and producers showing up on
+ the bridged destination, allowing for increased parallelism across high
+ latency networks. The default is `1`.
+
+ When using a `concurrency` value greater than 1 multiple bridges will be
+ created and named with an index. For example, if a bridge named `myBridge`
+ was configured with a `concurrency` of `3` then actually 3 bridges would
+ be created named `myBridge-0`, `myBridge-1`, and `myBridge-2`. This is
+ important to note for management operations as each bridge will have its
+ own associated `BridgeControl`.
- `static-connectors` or `discovery-group-ref`. Pick either of these options to
connect the bridge to the target server.
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java
index 3946933..550bcf4 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java
@@ -48,6 +48,7 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
+import org.apache.activemq.artemis.api.core.management.BridgeControl;
import org.apache.activemq.artemis.core.config.BridgeConfiguration;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.config.TransformerConfiguration;
@@ -2044,6 +2045,41 @@ public class BridgeTest extends ActiveMQTestBase {
Assert.assertNotNull(consumer.receive(200));
}
+ @Test
+ public void testManagementLeak() throws Exception {
+ final SimpleString ADDRESS = new SimpleString("myAddress");
+ final SimpleString QUEUE = new SimpleString("myQueue");
+ final SimpleString FORWARDING_ADDRESS = new SimpleString("myForwardingAddress");
+ final SimpleString FORWARDING_QUEUE = new SimpleString("myForwardingQueue");
+ final String BRIDGE = "myBridge";
+
+ ActiveMQServer server = addServer(new ActiveMQServerImpl(createDefaultConfig(0, isNetty()).addConnectorConfiguration("myConnector", new TransportConfiguration(getConnector()))));
+ server.start();
+ server.waitForActivation(100, TimeUnit.MILLISECONDS);
+ server.createQueue(new QueueConfiguration(QUEUE)
+ .setAddress(ADDRESS)
+ .setRoutingType(RoutingType.ANYCAST)
+ .setDurable(false));
+ server.createQueue(new QueueConfiguration(FORWARDING_QUEUE)
+ .setAddress(FORWARDING_ADDRESS)
+ .setRoutingType(RoutingType.ANYCAST)
+ .setDurable(false));
+ ArrayList<String> connectors = new ArrayList<>();
+ connectors.add("myConnector");
+ final int concurrency = 20;
+ BridgeConfiguration config = new BridgeConfiguration()
+ .setName(BRIDGE)
+ .setQueueName(QUEUE.toString())
+ .setForwardingAddress(FORWARDING_ADDRESS.toString())
+ .setStaticConnectors(connectors)
+ .setConcurrency(concurrency);
+ server.deployBridge(config);
+ assertEquals(concurrency, server.getManagementService().getResources(BridgeControl.class).length);
+ server.destroyBridge(config.getName());
+
+ assertEquals(0, server.getManagementService().getResources(BridgeControl.class).length);
+ }
+
/**
* It will inspect the journal directly and determine if there are queues on this journal,
*
[activemq-artemis] 01/03: ARTEMIS-3685 support reloading bridges
Posted by jb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jbertram pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit c51fda09cd6992c6d76d389127ed0b64d1d2e0df
Author: Justin Bertram <jb...@apache.org>
AuthorDate: Mon Feb 14 11:49:11 2022 -0600
ARTEMIS-3685 support reloading bridges
---
.../artemis/core/config/BridgeConfiguration.java | 28 ++++
.../artemis/core/server/ActiveMQServerLogger.java | 12 +-
.../artemis/core/server/cluster/Bridge.java | 3 +
.../core/server/cluster/ClusterManager.java | 12 +-
.../core/server/cluster/impl/BridgeImpl.java | 142 +++++++--------------
.../cluster/impl/ClusterConnectionBridge.java | 18 ++-
.../core/server/impl/ActiveMQServerImpl.java | 23 +++-
docs/user-manual/en/config-reload.md | 3 +-
.../tests/integration/jms/RedeployTest.java | 77 +++++++++++
.../src/test/resources/reload-bridge-updated.xml | 78 +++++++++++
.../src/test/resources/reload-bridge.xml | 78 +++++++++++
11 files changed, 355 insertions(+), 119 deletions(-)
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/BridgeConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/BridgeConfiguration.java
index da8709c..ea05aea 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/BridgeConfiguration.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/BridgeConfiguration.java
@@ -119,6 +119,34 @@ public final class BridgeConfiguration implements Serializable {
public BridgeConfiguration() {
}
+ public BridgeConfiguration(BridgeConfiguration other) {
+ name = other.name;
+ queueName = other.queueName;
+ forwardingAddress = other.forwardingAddress;
+ filterString = other.filterString;
+ staticConnectors = other.staticConnectors;
+ discoveryGroupName = other.discoveryGroupName;
+ ha = other.ha;
+ transformerConfiguration = other.transformerConfiguration;
+ retryInterval = other.retryInterval;
+ retryIntervalMultiplier = other.retryIntervalMultiplier;
+ initialConnectAttempts = other.initialConnectAttempts;
+ reconnectAttempts = other.reconnectAttempts;
+ reconnectAttemptsOnSameNode = other.reconnectAttemptsOnSameNode;
+ useDuplicateDetection = other.useDuplicateDetection;
+ confirmationWindowSize = other.confirmationWindowSize;
+ producerWindowSize = other.producerWindowSize;
+ clientFailureCheckPeriod = other.clientFailureCheckPeriod;
+ user = other.user;
+ password = other.password;
+ connectionTTL = other.connectionTTL;
+ maxRetryInterval = other.maxRetryInterval;
+ minLargeMessageSize = other.minLargeMessageSize;
+ callTimeout = other.callTimeout;
+ routingType = other.routingType;
+ concurrency = other.concurrency;
+ }
+
public BridgeConfiguration(String name) {
setName(name);
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
index b0676cd..87f0827 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
@@ -216,11 +216,11 @@ public interface ActiveMQServerLogger extends BasicLogger {
@LogMessage(level = Logger.Level.INFO)
@Message(id = 221029, value = "stopped bridge {0}", format = Message.Format.MESSAGE_FORMAT)
- void bridgeStopped(SimpleString name);
+ void bridgeStopped(String name);
@LogMessage(level = Logger.Level.INFO)
@Message(id = 221030, value = "paused bridge {0}", format = Message.Format.MESSAGE_FORMAT)
- void bridgePaused(SimpleString name);
+ void bridgePaused(String name);
@LogMessage(level = Logger.Level.INFO)
@Message(id = 221031, value = "backup announced", format = Message.Format.MESSAGE_FORMAT)
@@ -843,16 +843,16 @@ public interface ActiveMQServerLogger extends BasicLogger {
@LogMessage(level = Logger.Level.WARN)
@Message(id = 222096, value = "Error on querying binding on bridge {0}. Retrying in 100 milliseconds", format = Message.Format.MESSAGE_FORMAT)
- void errorQueryingBridge(@Cause Throwable t, SimpleString name);
+ void errorQueryingBridge(@Cause Throwable t, String name);
@LogMessage(level = Logger.Level.WARN)
@Message(id = 222097, value = "Address {0} does not have any bindings, retry #({1})",
format = Message.Format.MESSAGE_FORMAT)
- void errorQueryingBridge(SimpleString address, Integer retryCount);
+ void errorQueryingBridge(String address, Integer retryCount);
@LogMessage(level = Logger.Level.WARN)
@Message(id = 222098, value = "Server is starting, retry to create the session for bridge {0}", format = Message.Format.MESSAGE_FORMAT)
- void errorStartingBridge(SimpleString name);
+ void errorStartingBridge(String name);
@LogMessage(level = Logger.Level.WARN)
@Message(id = 222099, value = "Bridge {0} is unable to connect to destination. It will be disabled.", format = Message.Format.MESSAGE_FORMAT)
@@ -865,7 +865,7 @@ public interface ActiveMQServerLogger extends BasicLogger {
@LogMessage(level = Logger.Level.WARN)
@Message(id = 222101, value = "Bridge {0} achieved {1} maxattempts={2} it will stop retrying to reconnect", format = Message.Format.MESSAGE_FORMAT)
- void bridgeAbortStart(SimpleString name, Integer retryCount, Integer reconnectAttempts);
+ void bridgeAbortStart(String name, Integer retryCount, Integer reconnectAttempts);
@LogMessage(level = Logger.Level.WARN)
@Message(id = 222102, value = "Unexpected exception while trying to reconnect", format = Message.Format.MESSAGE_FORMAT)
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/Bridge.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/Bridge.java
index 28fbc7c..9cd1e3c 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/Bridge.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/Bridge.java
@@ -17,6 +17,7 @@
package org.apache.activemq.artemis.core.server.cluster;
import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.config.BridgeConfiguration;
import org.apache.activemq.artemis.core.server.ActiveMQComponent;
import org.apache.activemq.artemis.core.server.Consumer;
import org.apache.activemq.artemis.core.server.Queue;
@@ -55,4 +56,6 @@ public interface Bridge extends Consumer, ActiveMQComponent {
boolean isConnected();
BridgeMetrics getMetrics();
+
+ BridgeConfiguration getConfiguration();
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterManager.java
index da860d5..406ddd4 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterManager.java
@@ -40,7 +40,6 @@ import org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal;
import org.apache.activemq.artemis.core.config.BridgeConfiguration;
import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
import org.apache.activemq.artemis.core.config.Configuration;
-import org.apache.activemq.artemis.core.filter.impl.FilterImpl;
import org.apache.activemq.artemis.core.postoffice.Binding;
import org.apache.activemq.artemis.core.postoffice.PostOffice;
import org.apache.activemq.artemis.core.protocol.core.Channel;
@@ -53,7 +52,6 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.NodeManager;
import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.transformer.Transformer;
import org.apache.activemq.artemis.core.server.cluster.ha.HAManager;
import org.apache.activemq.artemis.core.server.cluster.impl.BridgeImpl;
import org.apache.activemq.artemis.core.server.cluster.impl.BroadcastGroupImpl;
@@ -401,8 +399,6 @@ public class ClusterManager implements ActiveMQComponent {
return false;
}
- Transformer transformer = server.getServiceRegistry().getBridgeTransformer(config.getName(), config.getTransformerConfiguration());
-
Binding binding = postOffice.getBinding(new SimpleString(config.getQueueName()));
if (binding == null) {
@@ -482,13 +478,7 @@ public class ClusterManager implements ActiveMQComponent {
for (int i = 0; i < config.getConcurrency(); i++) {
String name = config.getConcurrency() > 1 ? (config.getName() + "-" + i) : config.getName();
- Bridge bridge = new BridgeImpl(serverLocator, config.getInitialConnectAttempts(), config.getReconnectAttempts(),
- config.getReconnectAttemptsOnSameNode(), config.getRetryInterval(), config.getRetryIntervalMultiplier(),
- config.getMaxRetryInterval(), nodeManager.getUUID(), new SimpleString(name), queue,
- executorFactory.getExecutor(), FilterImpl.createFilter(config.getFilterString()),
- SimpleString.toSimpleString(config.getForwardingAddress()), scheduledExecutor, transformer,
- config.isUseDuplicateDetection(), config.getUser(), config.getPassword(), server,
- config.getRoutingType());
+ Bridge bridge = new BridgeImpl(serverLocator, new BridgeConfiguration(config).setName(name), nodeManager.getUUID(), queue, executorFactory.getExecutor(), scheduledExecutor, server);
bridges.put(name, bridge);
managementService.registerBridge(bridge, config);
bridge.start();
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java
index a737086..8b1b9fa 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java
@@ -50,10 +50,11 @@ import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl;
import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal;
import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal;
import org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal;
+import org.apache.activemq.artemis.core.config.BridgeConfiguration;
import org.apache.activemq.artemis.core.filter.Filter;
+import org.apache.activemq.artemis.core.filter.impl.FilterImpl;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
-import org.apache.activemq.artemis.core.server.ComponentConfigurationRoutingType;
import org.apache.activemq.artemis.core.server.HandleStatus;
import org.apache.activemq.artemis.core.server.LargeServerMessage;
import org.apache.activemq.artemis.core.server.MessageReference;
@@ -78,11 +79,8 @@ import org.jboss.logging.Logger;
public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowledgementHandler, ReadyListener, ClientProducerFlowCallback {
-
private static final Logger logger = Logger.getLogger(BridgeImpl.class);
-
-
protected final ServerLocatorInternal serverLocator;
protected final Executor executor;
@@ -95,36 +93,16 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
private final long sequentialID;
- private final SimpleString name;
-
protected final Queue queue;
private final Filter filter;
- private final SimpleString forwardingAddress;
-
final java.util.Map<Long, MessageReference> refs = new LinkedHashMap<>();
private final Transformer transformer;
private final Object connectionGuard = new Object();
- private final boolean useDuplicateDetection;
-
- private final String user;
-
- private final String password;
-
- private final int reconnectAttempts;
-
- private final int reconnectAttemptsSameNode;
-
- private final long retryInterval;
-
- private final double retryMultiplier;
-
- private final long maxRetryInterval;
-
private boolean blockedOnFlowControl;
/**
@@ -170,70 +148,35 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
private final BridgeMetrics metrics = new BridgeMetrics();
- private final ComponentConfigurationRoutingType routingType;
+ private BridgeConfiguration configuration;
public BridgeImpl(final ServerLocatorInternal serverLocator,
- final int initialConnectAttempts,
- final int reconnectAttempts,
- final int reconnectAttemptsSameNode,
- final long retryInterval,
- final double retryMultiplier,
- final long maxRetryInterval,
+ final BridgeConfiguration configuration,
final UUID nodeUUID,
- final SimpleString name,
final Queue queue,
final Executor executor,
- final Filter filter,
- final SimpleString forwardingAddress,
final ScheduledExecutorService scheduledExecutor,
- final Transformer transformer,
- final boolean useDuplicateDetection,
- final String user,
- final String password,
- final ActiveMQServer server,
- final ComponentConfigurationRoutingType routingType) {
+ final ActiveMQServer server) throws ActiveMQException {
this.sequentialID = server.getStorageManager().generateID();
- this.reconnectAttempts = reconnectAttempts;
-
- this.reconnectAttemptsInUse = initialConnectAttempts;
-
- this.reconnectAttemptsSameNode = reconnectAttemptsSameNode;
-
- this.retryInterval = retryInterval;
-
- this.retryMultiplier = retryMultiplier;
-
- this.maxRetryInterval = maxRetryInterval;
+ this.configuration = configuration;
this.serverLocator = serverLocator;
this.nodeUUID = nodeUUID;
- this.name = name;
-
this.queue = queue;
this.executor = executor;
this.scheduledExecutor = scheduledExecutor;
- this.filter = filter;
-
- this.forwardingAddress = forwardingAddress;
-
- this.transformer = transformer;
+ this.transformer = server.getServiceRegistry().getBridgeTransformer(configuration.getName(), configuration.getTransformerConfiguration());
- this.useDuplicateDetection = useDuplicateDetection;
-
- this.user = user;
-
- this.password = password;
+ this.filter = FilterImpl.createFilter(configuration.getFilterString());
this.server = server;
-
- this.routingType = routingType;
}
/** For tests mainly */
@@ -311,7 +254,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
if (notificationService != null) {
TypedProperties props = new TypedProperties();
- props.putSimpleStringProperty(new SimpleString("name"), name);
+ props.putSimpleStringProperty(new SimpleString("name"), SimpleString.toSimpleString(configuration.getName()));
Notification notification = new Notification(nodeUUID.toString(), CoreNotificationType.BRIDGE_STARTED, props);
notificationService.sendNotification(notification);
}
@@ -424,7 +367,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
stopping = true;
if (logger.isDebugEnabled()) {
- logger.debug("Bridge " + this.name + " being stopped");
+ logger.debug("Bridge " + this.configuration.getName() + " being stopped");
}
if (futureScheduledReconnection != null) {
@@ -435,7 +378,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
if (notificationService != null) {
TypedProperties props = new TypedProperties();
- props.putSimpleStringProperty(new SimpleString("name"), name);
+ props.putSimpleStringProperty(new SimpleString("name"), SimpleString.toSimpleString(configuration.getName()));
Notification notification = new Notification(nodeUUID.toString(), CoreNotificationType.BRIDGE_STOPPED, props);
try {
notificationService.sendNotification(notification);
@@ -448,14 +391,14 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
@Override
public void pause() throws Exception {
if (logger.isDebugEnabled()) {
- logger.debug("Bridge " + this.name + " being paused");
+ logger.debug("Bridge " + this.configuration.getName() + " being paused");
}
executor.execute(new PauseRunnable());
if (notificationService != null) {
TypedProperties props = new TypedProperties();
- props.putSimpleStringProperty(new SimpleString("name"), name);
+ props.putSimpleStringProperty(new SimpleString("name"), SimpleString.toSimpleString(configuration.getName()));
Notification notification = new Notification(nodeUUID.toString(), CoreNotificationType.BRIDGE_STOPPED, props);
try {
notificationService.sendNotification(notification);
@@ -482,7 +425,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
@Override
public SimpleString getName() {
- return name;
+ return SimpleString.toSimpleString(configuration.getName());
}
@Override
@@ -499,7 +442,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
@Override
public SimpleString getForwardingAddress() {
- return forwardingAddress;
+ return SimpleString.toSimpleString(configuration.getForwardingAddress());
}
// For testing only
@@ -561,7 +504,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
/** ClusterConnectionBridge already makes a copy of the message.
* So I needed I hook where the message is not copied. */
protected Message beforeForwardingNoCopy(Message message, SimpleString forwardingAddress) {
- if (useDuplicateDetection) {
+ if (configuration.isUseDuplicateDetection()) {
// We keep our own DuplicateID for the Bridge, so bouncing back and forth will work fine
byte[] bytes = getDuplicateBytes(nodeUUID, message.getMessageID());
@@ -573,7 +516,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
message.setAddress(forwardingAddress);
}
- switch (routingType) {
+ switch (configuration.getRoutingType()) {
case ANYCAST:
message.setRoutingType(RoutingType.ANYCAST);
break;
@@ -645,8 +588,8 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
final SimpleString dest;
- if (forwardingAddress != null) {
- dest = forwardingAddress;
+ if (configuration.getForwardingAddress() != null) {
+ dest = SimpleString.toSimpleString(configuration.getForwardingAddress());
} else {
// Preserve the original address
dest = ref.getMessage().getAddressSimpleString();
@@ -850,7 +793,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
return this.getClass().getSimpleName() + "@" +
Integer.toHexString(System.identityHashCode(this)) +
" [name=" +
- name +
+ configuration.getName() +
", queue=" +
queue +
" targetConnector=" +
@@ -862,7 +805,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
public String toManagementString() {
return this.getClass().getSimpleName() +
" [name=" +
- name +
+ configuration.getName() +
", queue=" +
queue.getName() + "/" + queue.getID() + "]";
}
@@ -875,6 +818,11 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
return transformer;
}
+ @Override
+ public BridgeConfiguration getConfiguration() {
+ return configuration;
+ }
+
protected void fail(final boolean permanently, boolean scaleDown) {
logger.debug(this + "\n\t::fail being called, permanently=" + permanently);
//we need to make sure we remove the node from the topology so any incoming quorum requests are voted correctly
@@ -907,7 +855,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
disconnectedAndDown = false;
}
retryCount = 0;
- reconnectAttemptsInUse = reconnectAttempts;
+ reconnectAttemptsInUse = configuration.getReconnectAttempts();
if (futureScheduledReconnection != null) {
futureScheduledReconnection.cancel(true);
futureScheduledReconnection = null;
@@ -916,7 +864,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
/* Hook for creating session factory */
protected ClientSessionFactoryInternal createSessionFactory() throws Exception {
- if (targetNodeID != null && (this.reconnectAttemptsSameNode < 0 || retryCount <= this.reconnectAttemptsSameNode)) {
+ if (targetNodeID != null && (this.configuration.getReconnectAttemptsOnSameNode() < 0 || retryCount <= this.configuration.getReconnectAttemptsOnSameNode())) {
csf = reconnectOnOriginalNode();
} else {
serverLocator.resetToInitialConnectors();
@@ -984,18 +932,18 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
return;
}
// Session is pre-acknowledge
- session = (ClientSessionInternal) csf.createSession(user, password, false, true, true, true, 1);
+ session = (ClientSessionInternal) csf.createSession(configuration.getUser(), configuration.getPassword(), false, true, true, true, 1);
session.getProducerCreditManager().setCallback(this);
- sessionConsumer = (ClientSessionInternal) csf.createSession(user, password, false, true, true, true, 1);
+ sessionConsumer = (ClientSessionInternal) csf.createSession(configuration.getUser(), configuration.getPassword(), false, true, true, true, 1);
}
- if (forwardingAddress != null) {
+ if (configuration.getForwardingAddress() != null) {
ClientSession.AddressQuery query = null;
try {
- query = session.addressQuery(forwardingAddress);
+ query = session.addressQuery(SimpleString.toSimpleString(configuration.getForwardingAddress()));
} catch (Throwable e) {
- ActiveMQServerLogger.LOGGER.errorQueryingBridge(e, name);
+ ActiveMQServerLogger.LOGGER.errorQueryingBridge(e, configuration.getName());
// This was an issue during startup, we will not count this retry
retryCount--;
@@ -1004,7 +952,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
}
if (!query.isExists()) {
- ActiveMQServerLogger.LOGGER.errorQueryingBridge(forwardingAddress, retryCount);
+ ActiveMQServerLogger.LOGGER.errorQueryingBridge(configuration.getForwardingAddress(), retryCount);
scheduleRetryConnect();
return;
}
@@ -1035,12 +983,12 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
} catch (ActiveMQException e) {
// the session was created while its server was starting, retry it:
if (e.getType() == ActiveMQExceptionType.SESSION_CREATION_REJECTED) {
- ActiveMQServerLogger.LOGGER.errorStartingBridge(name);
+ ActiveMQServerLogger.LOGGER.errorStartingBridge(configuration.getName());
// We are not going to count this one as a retry
retryCount--;
- scheduleRetryConnectFixedTimeout(this.retryInterval);
+ scheduleRetryConnectFixedTimeout(this.configuration.getRetryInterval());
return;
} else {
ActiveMQServerLogger.LOGGER.errorConnectingBridgeRetry(this);
@@ -1078,17 +1026,17 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
}
if (reconnectAttemptsInUse >= 0 && retryCount > reconnectAttemptsInUse) {
- ActiveMQServerLogger.LOGGER.bridgeAbortStart(name, retryCount, reconnectAttempts);
+ ActiveMQServerLogger.LOGGER.bridgeAbortStart(configuration.getName(), retryCount, configuration.getReconnectAttempts());
fail(true, false);
return;
}
- long timeout = (long) (this.retryInterval * Math.pow(this.retryMultiplier, retryCount));
+ long timeout = (long) (this.configuration.getRetryInterval() * Math.pow(this.configuration.getRetryIntervalMultiplier(), retryCount));
if (timeout == 0) {
- timeout = this.retryInterval;
+ timeout = this.configuration.getRetryInterval();
}
- if (timeout > maxRetryInterval) {
- timeout = maxRetryInterval;
+ if (timeout > configuration.getMaxRetryInterval()) {
+ timeout = configuration.getMaxRetryInterval();
}
logger.debug("Bridge " + this +
@@ -1135,7 +1083,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
return;
if (logger.isDebugEnabled()) {
- logger.debug("Scheduling retry for bridge " + this.name + " in " + milliseconds + " milliseconds");
+ logger.debug("Scheduling retry for bridge " + this.configuration.getName() + " in " + milliseconds + " milliseconds");
}
futureScheduledReconnection = scheduledExecutor.schedule(new FutureConnectRunnable(executor, this), milliseconds, TimeUnit.MILLISECONDS);
@@ -1197,7 +1145,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
queue.removeConsumer(BridgeImpl.this);
synchronized (BridgeImpl.this) {
- logger.debug("Closing Session for bridge " + BridgeImpl.this.name);
+ logger.debug("Closing Session for bridge " + BridgeImpl.this.configuration.getName());
started = false;
@@ -1237,7 +1185,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
if (logger.isTraceEnabled()) {
logger.trace("Removing consumer on stopRunnable " + this + " from queue " + queue);
}
- ActiveMQServerLogger.LOGGER.bridgeStopped(name);
+ ActiveMQServerLogger.LOGGER.bridgeStopped(configuration.getName());
}
}
@@ -1259,7 +1207,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
internalCancelReferences();
- ActiveMQServerLogger.LOGGER.bridgePaused(name);
+ ActiveMQServerLogger.LOGGER.bridgePaused(configuration.getName());
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.errorPausingBridge(e);
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java
index ff9a179..b99b6e9 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java
@@ -40,6 +40,7 @@ import org.apache.activemq.artemis.api.core.management.ResourceNames;
import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal;
import org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal;
import org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl;
+import org.apache.activemq.artemis.core.config.BridgeConfiguration;
import org.apache.activemq.artemis.core.filter.Filter;
import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.core.postoffice.BindingType;
@@ -118,9 +119,20 @@ public class ClusterConnectionBridge extends BridgeImpl {
final MessageFlowRecord flowRecord,
final TransportConfiguration connector,
final String storeAndForwardPrefix,
- final StorageManager storageManager) {
- super(targetLocator, initialConnectAttempts, reconnectAttempts, 0, // reconnectAttemptsOnSameNode means nothing on the clustering bridge since we always try the same
- retryInterval, retryMultiplier, maxRetryInterval, nodeUUID, name, queue, executor, filterString, forwardingAddress, scheduledExecutor, transformer, useDuplicateDetection, user, password, server, ComponentConfigurationRoutingType.valueOf(ActiveMQDefaultConfiguration.getDefaultBridgeRoutingType()));
+ final StorageManager storageManager) throws ActiveMQException {
+ super(targetLocator, new BridgeConfiguration()
+ .setInitialConnectAttempts(initialConnectAttempts)
+ .setReconnectAttempts(reconnectAttempts)
+ .setReconnectAttemptsOnSameNode(0) // reconnectAttemptsOnSameNode means nothing on the clustering bridge since we always try the same
+ .setRetryInterval(retryInterval)
+ .setRetryIntervalMultiplier(retryMultiplier)
+ .setMaxRetryInterval(maxRetryInterval)
+ .setFilterString(filterString.toString())
+ .setForwardingAddress(forwardingAddress.toString())
+ .setUseDuplicateDetection(useDuplicateDetection)
+ .setUser(user)
+ .setPassword(password)
+ .setRoutingType(ComponentConfigurationRoutingType.valueOf(ActiveMQDefaultConfiguration.getDefaultBridgeRoutingType())), nodeUUID, queue, executor, scheduledExecutor, server);
this.discoveryLocator = discoveryLocator;
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
index 0973910..daad672 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
@@ -143,7 +143,9 @@ import org.apache.activemq.artemis.core.server.ServerConsumer;
import org.apache.activemq.artemis.core.server.ServerSession;
import org.apache.activemq.artemis.core.server.ServiceComponent;
import org.apache.activemq.artemis.core.server.ServiceRegistry;
+import org.apache.activemq.artemis.core.server.balancing.BrokerBalancerManager;
import org.apache.activemq.artemis.core.server.cluster.BackupManager;
+import org.apache.activemq.artemis.core.server.cluster.Bridge;
import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
import org.apache.activemq.artemis.core.server.cluster.ClusterManager;
import org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy;
@@ -172,7 +174,6 @@ import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerMessagePlugi
import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerQueuePlugin;
import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerResourcePlugin;
import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerSessionPlugin;
-import org.apache.activemq.artemis.core.server.balancing.BrokerBalancerManager;
import org.apache.activemq.artemis.core.server.reload.ReloadManager;
import org.apache.activemq.artemis.core.server.reload.ReloadManagerImpl;
import org.apache.activemq.artemis.core.server.replay.ReplayManager;
@@ -4347,6 +4348,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
configuration.setDivertConfigurations(config.getDivertConfigurations());
configuration.setAddressConfigurations(config.getAddressConfigurations());
configuration.setQueueConfigs(config.getQueueConfigs());
+ configuration.setBridgeConfigurations(config.getBridgeConfigurations());
configurationReloadDeployed.set(false);
if (isActive()) {
configuration.parseProperties(propertiesFileUrl);
@@ -4415,6 +4417,25 @@ public class ActiveMQServerImpl implements ActiveMQServer {
undeployAddressesAndQueueNotInConfiguration(configuration);
deployAddressesFromConfiguration(configuration);
deployQueuesFromListQueueConfiguration(configuration.getQueueConfigs());
+
+ ActiveMQServerLogger.LOGGER.reloadingConfiguration("bridges");
+ for (BridgeConfiguration newBridgeConfig : configuration.getBridgeConfigurations()) {
+ Bridge existingBridge = clusterManager.getBridges().get(newBridgeConfig.getName());
+ if (existingBridge != null && !existingBridge.getConfiguration().equals(newBridgeConfig)) {
+ // this is an existing bridge but the config changed so stop the current bridge and deploy the new one
+ destroyBridge(existingBridge.getName().toString());
+ deployBridge(newBridgeConfig);
+ } else if (existingBridge == null) {
+ // this is a new bridge
+ deployBridge(newBridgeConfig);
+ }
+ }
+ for (final Bridge runningBridge: clusterManager.getBridges().values()) {
+ if (!configuration.getBridgeConfigurations().contains(runningBridge.getConfiguration())) {
+ // this bridge is running but it isn't in the new config which means it was removed so destroy it
+ destroyBridge(runningBridge.getName().toString());
+ }
+ }
}
}
diff --git a/docs/user-manual/en/config-reload.md b/docs/user-manual/en/config-reload.md
index f41520c..fdecb3c 100644
--- a/docs/user-manual/en/config-reload.md
+++ b/docs/user-manual/en/config-reload.md
@@ -10,7 +10,8 @@ be reloaded automatically:
- Address Settings
- Security Settings
- Diverts
-- Addresses & queues
+- Addresses & Queues
+- Bridges
If using [modulised broker.xml](configuration-index.md#modularising-broker.xml) ensure you also read [Reloading modular configuration files](configuration-index.md#reloading-modular-configuration-files)
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
index 88ef2a9..c893d75 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
@@ -489,6 +489,83 @@ public class RedeployTest extends ActiveMQTestBase {
}
}
+ @Test
+ public void testRedeployBridge() throws Exception {
+ Path brokerXML = getTestDirfile().toPath().resolve("broker.xml");
+ URL url1 = RedeployTest.class.getClassLoader().getResource("reload-bridge.xml");
+ URL url2 = RedeployTest.class.getClassLoader().getResource("reload-bridge-updated.xml");
+ Files.copy(url1.openStream(), brokerXML);
+
+ EmbeddedActiveMQ embeddedActiveMQ = new EmbeddedActiveMQ();
+ embeddedActiveMQ.setConfigResourcePath(brokerXML.toUri().toString());
+ embeddedActiveMQ.start();
+
+ final ReusableLatch latch = new ReusableLatch(1);
+
+ Runnable tick = latch::countDown;
+
+ embeddedActiveMQ.getActiveMQServer().getReloadManager().setTick(tick);
+
+ try {
+ latch.await(10, TimeUnit.SECONDS);
+
+ try (ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
+ Connection connection = factory.createConnection();
+ Session session = connection.createSession(Session.AUTO_ACKNOWLEDGE)) {
+ Queue queue = session.createQueue("a-from");
+ MessageProducer producer = session.createProducer(queue);
+ producer.send(session.createMessage());
+ Wait.assertEquals(1, () -> embeddedActiveMQ.getActiveMQServer().locateQueue("a-to").getMessageCount());
+ }
+
+ try (ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
+ Connection connection = factory.createConnection();
+ Session session = connection.createSession(Session.AUTO_ACKNOWLEDGE)) {
+ Queue queue = session.createQueue("b-from");
+ MessageProducer producer = session.createProducer(queue);
+ producer.send(session.createMessage());
+ Wait.assertEquals(1, () -> embeddedActiveMQ.getActiveMQServer().locateQueue("b-to").getMessageCount());
+ }
+
+ Files.copy(url2.openStream(), brokerXML, StandardCopyOption.REPLACE_EXISTING);
+ brokerXML.toFile().setLastModified(System.currentTimeMillis() + 1000);
+ latch.setCount(1);
+ embeddedActiveMQ.getActiveMQServer().getReloadManager().setTick(tick);
+ latch.await(10, TimeUnit.SECONDS);
+
+ try (ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
+ Connection connection = factory.createConnection();
+ Session session = connection.createSession(Session.AUTO_ACKNOWLEDGE)) {
+ Queue queue = session.createQueue("a-from");
+ MessageProducer producer = session.createProducer(queue);
+ producer.send(session.createMessage());
+ Wait.assertEquals(1, () -> embeddedActiveMQ.getActiveMQServer().locateQueue("a-new").getMessageCount());
+ Wait.assertEquals(1, () -> embeddedActiveMQ.getActiveMQServer().locateQueue("a-to").getMessageCount());
+ }
+
+ try (ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
+ Connection connection = factory.createConnection();
+ Session session = connection.createSession(Session.AUTO_ACKNOWLEDGE)) {
+ Queue queue = session.createQueue("b-from");
+ MessageProducer producer = session.createProducer(queue);
+ producer.send(session.createMessage());
+ assertFalse(Wait.waitFor(() -> embeddedActiveMQ.getActiveMQServer().locateQueue("b-to").getMessageCount() == 2, 2000, 100));
+ }
+
+ try (ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
+ Connection connection = factory.createConnection();
+ Session session = connection.createSession(Session.AUTO_ACKNOWLEDGE)) {
+ Queue queue = session.createQueue("c-from");
+ MessageProducer producer = session.createProducer(queue);
+ producer.send(session.createMessage());
+ Wait.assertEquals(1, () -> embeddedActiveMQ.getActiveMQServer().locateQueue("c-to").getMessageCount());
+ }
+
+ } finally {
+ embeddedActiveMQ.stop();
+ }
+ }
+
private void deployBrokerConfig(EmbeddedActiveMQ server, URL configFile) throws Exception {
Path brokerXML = getTestDirfile().toPath().resolve("broker.xml");
diff --git a/tests/integration-tests/src/test/resources/reload-bridge-updated.xml b/tests/integration-tests/src/test/resources/reload-bridge-updated.xml
new file mode 100644
index 0000000..c1b3035
--- /dev/null
+++ b/tests/integration-tests/src/test/resources/reload-bridge-updated.xml
@@ -0,0 +1,78 @@
+<?xml version='1.0'?>
+<!--
+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.
+-->
+
+<configuration xmlns="urn:activemq"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
+
+ <core xmlns="urn:activemq:core">
+ <security-enabled>false</security-enabled>
+ <persistence-enabled>false</persistence-enabled>
+ <configuration-file-refresh-period>100</configuration-file-refresh-period>
+
+ <acceptors>
+ <acceptor name="artemis">tcp://0.0.0.0:61616</acceptor>
+ </acceptors>
+
+ <connectors>
+ <connector name="connector">tcp://127.0.0.1:61616</connector>
+ </connectors>
+
+ <bridges>
+ <bridge name="a">
+ <queue-name>a-from</queue-name>
+ <forwarding-address>a-new</forwarding-address>
+ <static-connectors>
+ <connector-ref>connector</connector-ref>
+ </static-connectors>
+ </bridge>
+ <bridge name="c">
+ <queue-name>c-from</queue-name>
+ <forwarding-address>c-to</forwarding-address>
+ <static-connectors>
+ <connector-ref>connector</connector-ref>
+ </static-connectors>
+ </bridge>
+ </bridges>
+
+ <addresses>
+ <address name="a-new">
+ <anycast>
+ <queue name="a-new"/>
+ </anycast>
+ </address>
+ <address name="a-from">
+ <anycast>
+ <queue name="a-from"/>
+ </anycast>
+ </address>
+ <address name="c-to">
+ <anycast>
+ <queue name="c-to"/>
+ </anycast>
+ </address>
+ <address name="c-from">
+ <anycast>
+ <queue name="c-from"/>
+ </anycast>
+ </address>
+ </addresses>
+ </core>
+</configuration>
diff --git a/tests/integration-tests/src/test/resources/reload-bridge.xml b/tests/integration-tests/src/test/resources/reload-bridge.xml
new file mode 100644
index 0000000..96e069f
--- /dev/null
+++ b/tests/integration-tests/src/test/resources/reload-bridge.xml
@@ -0,0 +1,78 @@
+<?xml version='1.0'?>
+<!--
+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.
+-->
+
+<configuration xmlns="urn:activemq"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
+
+ <core xmlns="urn:activemq:core">
+ <security-enabled>false</security-enabled>
+ <persistence-enabled>false</persistence-enabled>
+ <configuration-file-refresh-period>100</configuration-file-refresh-period>
+
+ <acceptors>
+ <acceptor name="artemis">tcp://0.0.0.0:61616</acceptor>
+ </acceptors>
+
+ <connectors>
+ <connector name="connector">tcp://127.0.0.1:61616</connector>
+ </connectors>
+
+ <bridges>
+ <bridge name="a">
+ <queue-name>a-from</queue-name>
+ <forwarding-address>a-to</forwarding-address>
+ <static-connectors>
+ <connector-ref>connector</connector-ref>
+ </static-connectors>
+ </bridge>
+ <bridge name="b">
+ <queue-name>b-from</queue-name>
+ <forwarding-address>b-to</forwarding-address>
+ <static-connectors>
+ <connector-ref>connector</connector-ref>
+ </static-connectors>
+ </bridge>
+ </bridges>
+
+ <addresses>
+ <address name="a-to">
+ <anycast>
+ <queue name="a-to"/>
+ </anycast>
+ </address>
+ <address name="a-from">
+ <anycast>
+ <queue name="a-from"/>
+ </anycast>
+ </address>
+ <address name="b-to">
+ <anycast>
+ <queue name="b-to"/>
+ </anycast>
+ </address>
+ <address name="b-from">
+ <anycast>
+ <queue name="b-from"/>
+ </anycast>
+ </address>
+ </addresses>
+ </core>
+</configuration>