use of org.apache.activemq.artemis.core.config.CoreAddressConfiguration in project activemq-artemis by apache.
the class FileConfigurationParser method parseAddresses.
/**
* @param e
* @param config
*/
private void parseAddresses(final Element e, final Configuration config) {
NodeList elements = e.getElementsByTagName("addresses");
if (elements.getLength() != 0) {
Element node = (Element) elements.item(0);
NodeList list = node.getElementsByTagName("address");
for (int i = 0; i < list.getLength(); i++) {
CoreAddressConfiguration addrConfig = parseAddressConfiguration(list.item(i));
config.getAddressConfigurations().add(addrConfig);
}
}
}
use of org.apache.activemq.artemis.core.config.CoreAddressConfiguration in project activemq-artemis by apache.
the class FileConfigurationParser method parseAddressConfiguration.
protected CoreAddressConfiguration parseAddressConfiguration(final Node node) {
CoreAddressConfiguration addressConfiguration = new CoreAddressConfiguration();
String name = getAttributeValue(node, "name");
addressConfiguration.setName(name);
List<CoreQueueConfiguration> queueConfigurations = new ArrayList<>();
NodeList children = node.getChildNodes();
for (int j = 0; j < children.getLength(); j++) {
Node child = children.item(j);
if (child.getNodeName().equals("multicast")) {
addressConfiguration.addRoutingType(RoutingType.MULTICAST);
queueConfigurations.addAll(parseQueueConfigurations((Element) child, RoutingType.MULTICAST));
} else if (child.getNodeName().equals("anycast")) {
addressConfiguration.addRoutingType(RoutingType.ANYCAST);
queueConfigurations.addAll(parseQueueConfigurations((Element) child, RoutingType.ANYCAST));
}
}
for (CoreQueueConfiguration coreQueueConfiguration : queueConfigurations) {
coreQueueConfiguration.setAddress(name);
}
addressConfiguration.setQueueConfigurations(queueConfigurations);
return addressConfiguration;
}
use of org.apache.activemq.artemis.core.config.CoreAddressConfiguration in project activemq-artemis by apache.
the class FileBroker method start.
@Override
public synchronized void start() throws Exception {
if (started) {
return;
}
// todo if we start to pullout more configs from the main config then we should pull out the configuration objects from factories if available
FileConfiguration configuration = new FileConfiguration();
// Keep this as we still want to parse destinations in the <jms> element
FileJMSConfiguration jmsConfiguration = new FileJMSConfiguration();
FileDeploymentManager fileDeploymentManager = new FileDeploymentManager(configurationUrl);
fileDeploymentManager.addDeployable(configuration).addDeployable(jmsConfiguration);
fileDeploymentManager.readConfiguration();
createDirectories(configuration);
/**
* This is a bit of a hack for backwards config compatibility since we no longer want to start the broker
* using the JMSServerManager which would normally deploy JMS destinations. Here we take the JMS destination
* configurations from the parsed JMS configuration and add them to the core configuration.
*
* It's also important here that we are adding them to the core ADDRESS configurations as those will be
* deployed first and therefore their configuration will take precedence over other legacy queue configurations
* which are deployed later. This is so we can maintain support for configurations like those found in the
* bridge and divert examples where there are JMS and core queues with the same name (which was itself a bit
* of a hack).
*
* This should be removed when support for the old "jms" configuation element is also removed.
*/
{
for (JMSQueueConfiguration jmsQueueConfig : jmsConfiguration.getQueueConfigurations()) {
List<CoreAddressConfiguration> coreAddressConfigurations = configuration.getAddressConfigurations();
coreAddressConfigurations.add(new CoreAddressConfiguration().setName(jmsQueueConfig.getName()).addRoutingType(RoutingType.ANYCAST).addQueueConfiguration(new CoreQueueConfiguration().setAddress(jmsQueueConfig.getName()).setName(jmsQueueConfig.getName()).setFilterString(jmsQueueConfig.getSelector()).setRoutingType(RoutingType.ANYCAST)));
}
for (TopicConfiguration topicConfig : jmsConfiguration.getTopicConfigurations()) {
List<CoreAddressConfiguration> coreAddressConfigurations = configuration.getAddressConfigurations();
coreAddressConfigurations.add(new CoreAddressConfiguration().setName(topicConfig.getName()).addRoutingType(RoutingType.MULTICAST));
}
}
components = fileDeploymentManager.buildService(securityManager, ManagementFactory.getPlatformMBeanServer());
ArrayList<ActiveMQComponent> componentsByStartOrder = getComponentsByStartOrder(components);
ActiveMQBootstrapLogger.LOGGER.serverStarting();
for (ActiveMQComponent component : componentsByStartOrder) {
component.start();
}
started = true;
}
use of org.apache.activemq.artemis.core.config.CoreAddressConfiguration in project activemq-artemis by apache.
the class MultiThreadRandomReattachTest method start.
@Override
protected void start() throws Exception {
Configuration liveConf = createDefaultInVMConfig();
server = createServer(false, liveConf);
server.getConfiguration().getAddressConfigurations().add(new CoreAddressConfiguration().setName(ADDRESS.toString()).addRoutingType(RoutingType.MULTICAST));
server.start();
waitForServerToStart(server);
}
use of org.apache.activemq.artemis.core.config.CoreAddressConfiguration in project activemq-artemis by apache.
the class FileConfigurationTest method verifyAddresses.
private void verifyAddresses() {
assertEquals(3, conf.getAddressConfigurations().size());
// Addr 1
CoreAddressConfiguration addressConfiguration = conf.getAddressConfigurations().get(0);
assertEquals("addr1", addressConfiguration.getName());
Set<RoutingType> routingTypes = new HashSet<>();
routingTypes.add(RoutingType.ANYCAST);
assertEquals(routingTypes, addressConfiguration.getRoutingTypes());
assertEquals(2, addressConfiguration.getQueueConfigurations().size());
// Addr 1 Queue 1
CoreQueueConfiguration queueConfiguration = addressConfiguration.getQueueConfigurations().get(0);
assertEquals("q1", queueConfiguration.getName());
assertFalse(queueConfiguration.isDurable());
assertEquals("color='blue'", queueConfiguration.getFilterString());
assertEquals(ActiveMQDefaultConfiguration.getDefaultPurgeOnNoConsumers(), queueConfiguration.getPurgeOnNoConsumers());
assertEquals("addr1", queueConfiguration.getAddress());
assertEquals(ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(), queueConfiguration.getMaxConsumers());
// Addr 1 Queue 2
queueConfiguration = addressConfiguration.getQueueConfigurations().get(1);
assertEquals("q2", queueConfiguration.getName());
assertTrue(queueConfiguration.isDurable());
assertEquals("color='green'", queueConfiguration.getFilterString());
assertEquals(Queue.MAX_CONSUMERS_UNLIMITED, queueConfiguration.getMaxConsumers());
assertFalse(queueConfiguration.getPurgeOnNoConsumers());
assertEquals("addr1", queueConfiguration.getAddress());
// Addr 2
addressConfiguration = conf.getAddressConfigurations().get(1);
assertEquals("addr2", addressConfiguration.getName());
routingTypes = new HashSet<>();
routingTypes.add(RoutingType.MULTICAST);
assertEquals(routingTypes, addressConfiguration.getRoutingTypes());
assertEquals(2, addressConfiguration.getQueueConfigurations().size());
// Addr 2 Queue 1
queueConfiguration = addressConfiguration.getQueueConfigurations().get(0);
assertEquals("q3", queueConfiguration.getName());
assertTrue(queueConfiguration.isDurable());
assertEquals("color='red'", queueConfiguration.getFilterString());
assertEquals(10, queueConfiguration.getMaxConsumers());
assertEquals(ActiveMQDefaultConfiguration.getDefaultPurgeOnNoConsumers(), queueConfiguration.getPurgeOnNoConsumers());
assertEquals("addr2", queueConfiguration.getAddress());
// Addr 2 Queue 2
queueConfiguration = addressConfiguration.getQueueConfigurations().get(1);
assertEquals("q4", queueConfiguration.getName());
assertTrue(queueConfiguration.isDurable());
assertNull(queueConfiguration.getFilterString());
assertEquals(ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(), queueConfiguration.getMaxConsumers());
assertTrue(queueConfiguration.getPurgeOnNoConsumers());
assertEquals("addr2", queueConfiguration.getAddress());
// Addr 3
addressConfiguration = conf.getAddressConfigurations().get(2);
assertEquals("addr2", addressConfiguration.getName());
routingTypes = new HashSet<>();
routingTypes.add(RoutingType.MULTICAST);
routingTypes.add(RoutingType.ANYCAST);
assertEquals(routingTypes, addressConfiguration.getRoutingTypes());
}
Aggregations