ARTEMIS-4516 support reloading connectors from XML
This commit is contained in:
parent
9baad30827
commit
b24f9b25f0
|
@ -4623,6 +4623,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
||||||
configuration.setAddressConfigurations(config.getAddressConfigurations());
|
configuration.setAddressConfigurations(config.getAddressConfigurations());
|
||||||
configuration.setQueueConfigs(config.getQueueConfigs());
|
configuration.setQueueConfigs(config.getQueueConfigs());
|
||||||
configuration.setBridgeConfigurations(config.getBridgeConfigurations());
|
configuration.setBridgeConfigurations(config.getBridgeConfigurations());
|
||||||
|
configuration.setConnectorConfigurations(config.getConnectorConfigurations());
|
||||||
configurationReloadDeployed.set(false);
|
configurationReloadDeployed.set(false);
|
||||||
if (isActive()) {
|
if (isActive()) {
|
||||||
configuration.parseProperties(propertiesFileUrl);
|
configuration.parseProperties(propertiesFileUrl);
|
||||||
|
|
|
@ -47,6 +47,7 @@ import org.apache.activemq.artemis.core.postoffice.Binding;
|
||||||
import org.apache.activemq.artemis.core.postoffice.QueueBinding;
|
import org.apache.activemq.artemis.core.postoffice.QueueBinding;
|
||||||
import org.apache.activemq.artemis.core.postoffice.impl.DivertBinding;
|
import org.apache.activemq.artemis.core.postoffice.impl.DivertBinding;
|
||||||
import org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding;
|
import org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding;
|
||||||
|
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
|
||||||
import org.apache.activemq.artemis.core.security.Role;
|
import org.apache.activemq.artemis.core.security.Role;
|
||||||
import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
|
import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
|
||||||
import org.apache.activemq.artemis.core.server.cluster.impl.RemoteQueueBindingImpl;
|
import org.apache.activemq.artemis.core.server.cluster.impl.RemoteQueueBindingImpl;
|
||||||
|
@ -189,6 +190,42 @@ public class RedeployTest extends ActiveMQTestBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRedeployConnector() throws Exception {
|
||||||
|
Path brokerXML = getTestDirfile().toPath().resolve("broker.xml");
|
||||||
|
URL url1 = RedeployTest.class.getClassLoader().getResource("reload-connector.xml");
|
||||||
|
URL url2 = RedeployTest.class.getClassLoader().getResource("reload-connector-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);
|
||||||
|
Assert.assertEquals("127.0.0.1", embeddedActiveMQ.getActiveMQServer().getConfiguration().getConnectorConfigurations().get("artemis").getParams().get(TransportConstants.HOST_PROP_NAME));
|
||||||
|
Assert.assertEquals("61616", embeddedActiveMQ.getActiveMQServer().getConfiguration().getConnectorConfigurations().get("artemis").getParams().get(TransportConstants.PORT_PROP_NAME));
|
||||||
|
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);
|
||||||
|
|
||||||
|
Assert.assertEquals("127.0.0.2", embeddedActiveMQ.getActiveMQServer().getConfiguration().getConnectorConfigurations().get("artemis").getParams().get(TransportConstants.HOST_PROP_NAME));
|
||||||
|
Assert.assertEquals("61617", embeddedActiveMQ.getActiveMQServer().getConfiguration().getConnectorConfigurations().get("artemis").getParams().get(TransportConstants.PORT_PROP_NAME));
|
||||||
|
Assert.assertEquals("127.0.0.3", embeddedActiveMQ.getActiveMQServer().getConfiguration().getConnectorConfigurations().get("artemis2").getParams().get(TransportConstants.HOST_PROP_NAME));
|
||||||
|
Assert.assertEquals("61618", embeddedActiveMQ.getActiveMQServer().getConfiguration().getConnectorConfigurations().get("artemis2").getParams().get(TransportConstants.PORT_PROP_NAME));
|
||||||
|
} finally {
|
||||||
|
embeddedActiveMQ.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRedeploySecuritySettings() throws Exception {
|
public void testRedeploySecuritySettings() throws Exception {
|
||||||
Path brokerXML = getTestDirfile().toPath().resolve("broker.xml");
|
Path brokerXML = getTestDirfile().toPath().resolve("broker.xml");
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?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">
|
||||||
|
|
||||||
|
<configuration-file-refresh-period>100</configuration-file-refresh-period>
|
||||||
|
|
||||||
|
<persistence-enabled>false</persistence-enabled>
|
||||||
|
|
||||||
|
<connectors>
|
||||||
|
<connector name="artemis">tcp://127.0.0.2:61617</connector>
|
||||||
|
<connector name="artemis2">tcp://127.0.0.3:61618</connector>
|
||||||
|
</connectors>
|
||||||
|
</core>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?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">
|
||||||
|
|
||||||
|
<configuration-file-refresh-period>100</configuration-file-refresh-period>
|
||||||
|
|
||||||
|
<persistence-enabled>false</persistence-enabled>
|
||||||
|
|
||||||
|
<connectors>
|
||||||
|
<connector name="artemis">tcp://127.0.0.1:61616</connector>
|
||||||
|
</connectors>
|
||||||
|
</core>
|
||||||
|
</configuration>
|
Loading…
Reference in New Issue