Search in sources :

Example 1 with CoreAddressConfiguration

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);
        }
    }
}
Also used : NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) CoreAddressConfiguration(org.apache.activemq.artemis.core.config.CoreAddressConfiguration)

Example 2 with CoreAddressConfiguration

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;
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) CoreAddressConfiguration(org.apache.activemq.artemis.core.config.CoreAddressConfiguration) CoreQueueConfiguration(org.apache.activemq.artemis.core.config.CoreQueueConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 3 with CoreAddressConfiguration

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;
}
Also used : FileConfiguration(org.apache.activemq.artemis.core.config.impl.FileConfiguration) JMSQueueConfiguration(org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration) ActiveMQComponent(org.apache.activemq.artemis.core.server.ActiveMQComponent) FileJMSConfiguration(org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration) CoreAddressConfiguration(org.apache.activemq.artemis.core.config.CoreAddressConfiguration) ArrayList(java.util.ArrayList) List(java.util.List) CoreQueueConfiguration(org.apache.activemq.artemis.core.config.CoreQueueConfiguration) TopicConfiguration(org.apache.activemq.artemis.jms.server.config.TopicConfiguration) FileDeploymentManager(org.apache.activemq.artemis.core.config.FileDeploymentManager)

Example 4 with CoreAddressConfiguration

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);
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) CoreAddressConfiguration(org.apache.activemq.artemis.core.config.CoreAddressConfiguration) CoreAddressConfiguration(org.apache.activemq.artemis.core.config.CoreAddressConfiguration)

Example 5 with CoreAddressConfiguration

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());
}
Also used : CoreAddressConfiguration(org.apache.activemq.artemis.core.config.CoreAddressConfiguration) CoreQueueConfiguration(org.apache.activemq.artemis.core.config.CoreQueueConfiguration) RoutingType(org.apache.activemq.artemis.api.core.RoutingType) HashSet(java.util.HashSet)

Aggregations

CoreAddressConfiguration (org.apache.activemq.artemis.core.config.CoreAddressConfiguration)15 CoreQueueConfiguration (org.apache.activemq.artemis.core.config.CoreQueueConfiguration)8 Configuration (org.apache.activemq.artemis.core.config.Configuration)3 ArrayList (java.util.ArrayList)2 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)2 EmbeddedActiveMQ (org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ)2 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)2 JMSQueueConfiguration (org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration)2 TopicConfiguration (org.apache.activemq.artemis.jms.server.config.TopicConfiguration)2 Bean (org.springframework.context.annotation.Bean)2 Element (org.w3c.dom.Element)2 NodeList (org.w3c.dom.NodeList)2 HashSet (java.util.HashSet)1 List (java.util.List)1 QueueConfiguration (org.apache.activemq.artemis.api.core.QueueConfiguration)1 RoutingType (org.apache.activemq.artemis.api.core.RoutingType)1 FileDeploymentManager (org.apache.activemq.artemis.core.config.FileDeploymentManager)1 WildcardConfiguration (org.apache.activemq.artemis.core.config.WildcardConfiguration)1 ConfigurationImpl (org.apache.activemq.artemis.core.config.impl.ConfigurationImpl)1 FileConfiguration (org.apache.activemq.artemis.core.config.impl.FileConfiguration)1