Search in sources :

Example 1 with CoreQueueConfiguration

use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration 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 2 with CoreQueueConfiguration

use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration 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 3 with CoreQueueConfiguration

use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration in project activemq-artemis by apache.

the class LargeMessageOverReplicationTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    ruleFired.setCount(1);
    messageChunkCount = 0;
    TransportConfiguration liveConnector = TransportConfigurationUtils.getNettyConnector(true, 0);
    TransportConfiguration liveAcceptor = TransportConfigurationUtils.getNettyAcceptor(true, 0);
    TransportConfiguration backupConnector = TransportConfigurationUtils.getNettyConnector(false, 0);
    TransportConfiguration backupAcceptor = TransportConfigurationUtils.getNettyAcceptor(false, 0);
    Configuration backupConfig = createDefaultInVMConfig().setBindingsDirectory(getBindingsDir(0, true)).setJournalDirectory(getJournalDir(0, true)).setPagingDirectory(getPageDir(0, true)).setLargeMessagesDirectory(getLargeMessagesDir(0, true));
    Configuration liveConfig = createDefaultInVMConfig();
    ReplicatedBackupUtils.configureReplicationPair(backupConfig, backupConnector, backupAcceptor, liveConfig, liveConnector, liveAcceptor);
    liveServer = createServer(liveConfig);
    liveServer.getConfiguration().addQueueConfiguration(new CoreQueueConfiguration().setName("Queue").setAddress("Queue"));
    liveServer.start();
    waitForServerToStart(liveServer);
    backupServer = createServer(backupConfig);
    backupServer.start();
    waitForServerToStart(backupServer);
    // Just to make sure the expression worked
    Assert.assertEquals(10000, factory.getMinLargeMessageSize());
    Assert.assertEquals(10000, factory.getProducerWindowSize());
    Assert.assertEquals(100, factory.getRetryInterval());
    Assert.assertEquals(-1, factory.getReconnectAttempts());
    Assert.assertTrue(factory.isHA());
    connection = (ActiveMQConnection) factory.createConnection();
    waitForRemoteBackup(connection.getSessionFactory(), 30);
    session = connection.createSession(true, Session.SESSION_TRANSACTED);
    queue = session.createQueue("Queue");
    producer = session.createProducer(queue);
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) CoreQueueConfiguration(org.apache.activemq.artemis.core.config.CoreQueueConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) CoreQueueConfiguration(org.apache.activemq.artemis.core.config.CoreQueueConfiguration) Before(org.junit.Before)

Example 4 with CoreQueueConfiguration

use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration 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)

Example 5 with CoreQueueConfiguration

use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration in project activemq-artemis by apache.

the class MQTTTest method testBrokerRestartAfterSubHashWithConfigurationQueues.

@Test(timeout = 60 * 1000)
public void testBrokerRestartAfterSubHashWithConfigurationQueues() throws Exception {
    // Add some pre configured queues
    CoreQueueConfiguration coreQueueConfiguration = new CoreQueueConfiguration();
    coreQueueConfiguration.setName("DLQ");
    coreQueueConfiguration.setRoutingType(RoutingType.ANYCAST);
    coreQueueConfiguration.setAddress("DLA");
    CoreAddressConfiguration coreAddressConfiguration = new CoreAddressConfiguration();
    coreAddressConfiguration.setName("DLA");
    coreAddressConfiguration.addRoutingType(RoutingType.ANYCAST);
    coreAddressConfiguration.addQueueConfiguration(coreQueueConfiguration);
    getServer().getConfiguration().getAddressConfigurations().add(coreAddressConfiguration);
    getServer().stop();
    getServer().start();
    getServer().waitForActivation(10, TimeUnit.SECONDS);
    for (int i = 0; i < 2; i++) {
        MQTT mqtt = createMQTTConnection("myClient", false);
        BlockingConnection connection = mqtt.blockingConnection();
        connection.connect();
        connection.subscribe(new Topic[] { new Topic("#", QoS.AT_MOST_ONCE) });
        connection.disconnect();
        getServer().stop();
        getServer().start();
        getServer().waitForActivation(10, TimeUnit.SECONDS);
    }
}
Also used : MQTT(org.fusesource.mqtt.client.MQTT) CoreAddressConfiguration(org.apache.activemq.artemis.core.config.CoreAddressConfiguration) CoreQueueConfiguration(org.apache.activemq.artemis.core.config.CoreQueueConfiguration) BlockingConnection(org.fusesource.mqtt.client.BlockingConnection) Topic(org.fusesource.mqtt.client.Topic) Test(org.junit.Test)

Aggregations

CoreQueueConfiguration (org.apache.activemq.artemis.core.config.CoreQueueConfiguration)63 ArrayList (java.util.ArrayList)40 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)39 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)39 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)33 BridgeConfiguration (org.apache.activemq.artemis.core.config.BridgeConfiguration)32 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)31 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)31 Test (org.junit.Test)31 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)30 HashMap (java.util.HashMap)26 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)26 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)22 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)16 Configuration (org.apache.activemq.artemis.core.config.Configuration)9 Before (org.junit.Before)9 CoreAddressConfiguration (org.apache.activemq.artemis.core.config.CoreAddressConfiguration)8 Bridge (org.apache.activemq.artemis.core.server.cluster.Bridge)8 InVMAcceptorFactory (org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory)5 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)4