Search in sources :

Example 96 with Configuration

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

the class FailoverRandomTest method setUp.

@Before
public void setUp() throws Exception {
    Map<String, String> params = new HashMap<>();
    params.put("rebalanceClusterClients", "true");
    params.put("updateClusterClients", "true");
    params.put("updateClusterClientsOnRemove", "true");
    params.put("brokerName", "A");
    Configuration config0 = createConfig("127.0.0.1", 0, params);
    params.put("brokerName", "B");
    Configuration config1 = createConfig("127.0.0.2", 1, params);
    deployClusterConfiguration(config0, 1);
    deployClusterConfiguration(config1, 0);
    server0 = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    server1 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    server0.start();
    server1.start();
    Assert.assertTrue(server0.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    Assert.assertTrue(server1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
}
Also used : EmbeddedJMS(org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS) Configuration(org.apache.activemq.artemis.core.config.Configuration) HashMap(java.util.HashMap) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) Before(org.junit.Before)

Example 97 with Configuration

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

the class FailoverTimeoutTest method setUp.

@Before
public void setUp() throws Exception {
    Configuration config = createConfig(0);
    server = new EmbeddedJMS().setConfiguration(config).setJmsConfiguration(new JMSConfigurationImpl());
    server.start();
    tcpUri = new URI(newURI(0));
}
Also used : EmbeddedJMS(org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS) Configuration(org.apache.activemq.artemis.core.config.Configuration) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) URI(java.net.URI) Before(org.junit.Before)

Example 98 with Configuration

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

the class FailoverPriorityTest method restart.

private void restart(boolean primary, int primaryID, int secondaryID, int total) throws Exception {
    Thread.sleep(1000);
    if (primary) {
        LOG.info("Stopping " + primaryID);
        stopBroker(primaryID);
        Assert.assertTrue(servers[secondaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total - 1));
    } else {
        LOG.info("Stopping " + secondaryID);
        stopBroker(secondaryID);
        Assert.assertTrue(servers[primaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total - 1));
    }
    Thread.sleep(5000);
    if (primary) {
        assertAllConnectedTo(urls.get(secondaryID));
    } else {
        assertAllConnectedTo(urls.get(primaryID));
    }
    if (primary) {
        Configuration config = createConfig("127.0.0.1", primaryID);
        deployClusterConfiguration(config, secondaryID);
        servers[primaryID] = new EmbeddedJMS().setConfiguration(config).setJmsConfiguration(new JMSConfigurationImpl());
        servers[primaryID].start();
        Assert.assertTrue(servers[primaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total));
        Assert.assertTrue(servers[secondaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total));
    } else {
        Configuration config = createConfig("127.0.0.1", secondaryID);
        deployClusterConfiguration(config, primaryID);
        servers[secondaryID] = new EmbeddedJMS().setConfiguration(config).setJmsConfiguration(new JMSConfigurationImpl());
        servers[secondaryID].start();
        Assert.assertTrue(servers[primaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total));
        Assert.assertTrue(servers[secondaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total));
    }
    Thread.sleep(5000);
    assertAllConnectedTo(urls.get(primaryID));
}
Also used : EmbeddedJMS(org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS) Configuration(org.apache.activemq.artemis.core.config.Configuration) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl)

Example 99 with Configuration

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

the class FailoverPriorityTest method testPriorityBackupAndUpdateClients.

@Test
public void testPriorityBackupAndUpdateClients() throws Exception {
    Configuration config0 = createConfig("127.0.0.1", 0);
    Configuration config1 = createConfig("127.0.0.1", 1);
    deployClusterConfiguration(config0, 1);
    deployClusterConfiguration(config1, 0);
    servers[0] = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    servers[1] = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    servers[0].start();
    servers[1].start();
    Assert.assertTrue(servers[0].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    Assert.assertTrue(servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    Thread.sleep(1000);
    setClientUrl("failover:(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")?randomize=false&priorityBackup=true&initialReconnectDelay=1000&useExponentialBackOff=false");
    createClients(5);
    // Let's wait a little bit longer just in case it takes a while to realize that the
    // Broker A is the one with higher priority.
    Thread.sleep(5000);
    assertAllConnectedTo(urls.get(0));
}
Also used : EmbeddedJMS(org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS) Configuration(org.apache.activemq.artemis.core.config.Configuration) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) Test(org.junit.Test) OpenwireArtemisBaseTest(org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest)

Example 100 with Configuration

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

the class FailoverBackupLeakTest method setUp.

@Before
public void setUp() throws Exception {
    Configuration config0 = createConfig("127.0.0.1", 0);
    Configuration config1 = createConfig("127.0.0.1", 1);
    deployClusterConfiguration(config0, 1);
    deployClusterConfiguration(config1, 0);
    s1 = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    s2 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    s1.start();
    s2.start();
    Assert.assertTrue(s1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    Assert.assertTrue(s2.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
}
Also used : EmbeddedJMS(org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS) Configuration(org.apache.activemq.artemis.core.config.Configuration) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) Before(org.junit.Before)

Aggregations

Configuration (org.apache.activemq.artemis.core.config.Configuration)331 Test (org.junit.Test)143 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)120 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)109 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)108 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)101 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)93 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)90 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)81 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)78 StoreConfiguration (org.apache.activemq.artemis.core.config.StoreConfiguration)78 DivertConfiguration (org.apache.activemq.artemis.core.config.DivertConfiguration)72 Before (org.junit.Before)59 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)58 DatabaseStorageConfiguration (org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration)57 HashMap (java.util.HashMap)56 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)52 ActiveMQDefaultConfiguration (org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration)35 SharedStoreMasterPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration)35 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)34