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 4c30573233..bcfab14924 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 @@ -4579,13 +4579,18 @@ public class ActiveMQServerImpl implements ActiveMQServer { deployBridge(newBridgeConfig); } } - for (final Bridge runningBridge: clusterManager.getBridges().values()) { - List newConfig = configuration.getBridgeConfigurations(); - BridgeConfiguration running = new BridgeConfiguration(runningBridge.getConfiguration()); - running.set("name", running.getParentName()); - if (!configuration.getBridgeConfigurations().contains(running) && running.isConfigurationManaged()) { + for (final Bridge existingBridge: clusterManager.getBridges().values()) { + BridgeConfiguration existingBridgeConfig = existingBridge.getConfiguration(); + boolean destroy = true; + for (final BridgeConfiguration newBridgeConfig : configuration.getBridgeConfigurations()) { + if (existingBridgeConfig.isConfigurationManaged() && (existingBridgeConfig.getParentName().equals(newBridgeConfig.getName()) || existingBridgeConfig.getName().equals(newBridgeConfig.getName()) )) { + destroy = false; + break; + } + } + if (destroy) { // this bridge is running but it isn't in the new config which means it was removed so destroy it - destroyBridge(runningBridge.getName().toString()); + destroyBridge(existingBridge.getConfiguration().getParentName()); } } recoverStoredBridges(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/BridgeConfigurationStorageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/BridgeConfigurationStorageTest.java index ff387077f0..3cf860335b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/BridgeConfigurationStorageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/BridgeConfigurationStorageTest.java @@ -93,6 +93,7 @@ public class BridgeConfigurationStorageTest extends StorageManagerTestBase { BridgeConfiguration configuration = new BridgeConfiguration(); configuration.setName("name"); + configuration.setParentName("name"); configuration.setQueueName("QueueName"); configuration.setConcurrency(2); configuration.setForwardingAddress("forward");