Search in sources :

Example 91 with Configuration

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

the class SimpleSendReceiveSoakTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    clearDataRecreateServerDirs();
    Configuration config = createDefaultConfig(isNetty()).setJournalFileSize(10 * 1024 * 1024);
    server = createServer(IS_JOURNAL, config, -1, -1, new HashMap<String, AddressSettings>());
    server.start();
    ServerLocator locator = createFactory(isNetty());
    ClientSessionFactory sf = createSessionFactory(locator);
    ClientSession session = sf.createSession();
    session.createQueue(SimpleSendReceiveSoakTest.ADDRESS, SimpleSendReceiveSoakTest.ADDRESS, true);
    session.close();
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) HashMap(java.util.HashMap) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) Before(org.junit.Before)

Example 92 with Configuration

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

the class ClientSoakTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    clearDataRecreateServerDirs();
    Configuration config = createDefaultConfig(isNetty()).setJournalFileSize(10 * 1024 * 1024);
    server = createServer(IS_JOURNAL, config, -1, -1, new HashMap<String, AddressSettings>());
    DivertConfiguration divert1 = new DivertConfiguration().setName("dv1").setRoutingName("nm1").setAddress(ClientSoakTest.ADDRESS.toString()).setForwardingAddress(ClientSoakTest.DIVERTED_AD1.toString()).setExclusive(true);
    DivertConfiguration divert2 = new DivertConfiguration().setName("dv2").setRoutingName("nm2").setAddress(ClientSoakTest.ADDRESS.toString()).setForwardingAddress(ClientSoakTest.DIVERTED_AD2.toString()).setExclusive(true);
    ArrayList<DivertConfiguration> divertList = new ArrayList<>();
    divertList.add(divert1);
    divertList.add(divert2);
    config.setDivertConfigurations(divertList);
    server.start();
    ServerLocator locator = createFactory(isNetty());
    ClientSessionFactory sf = createSessionFactory(locator);
    ClientSession session = sf.createSession();
    session.createQueue(ClientSoakTest.ADDRESS, ClientSoakTest.ADDRESS, true);
    session.createQueue(ClientSoakTest.DIVERTED_AD1, ClientSoakTest.DIVERTED_AD1, true);
    session.createQueue(ClientSoakTest.DIVERTED_AD2, ClientSoakTest.DIVERTED_AD2, true);
    session.close();
    sf.close();
    locator.close();
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) DivertConfiguration(org.apache.activemq.artemis.core.config.DivertConfiguration) HashMap(java.util.HashMap) DivertConfiguration(org.apache.activemq.artemis.core.config.DivertConfiguration) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ArrayList(java.util.ArrayList) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) Before(org.junit.Before)

Example 93 with Configuration

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

the class SpawnedJMSServer method startServer.

public static ActiveMQServer startServer() throws Exception {
    if (server == null) {
        Configuration config = new ConfigurationImpl().addAcceptorConfiguration("netty", "tcp://localhost:61616").setSecurityEnabled(false).addConnectorConfiguration("netty", "tcp://localhost:61616");
        File dataPlace = new File("./target/dataJoram");
        FileUtil.deleteDirectory(dataPlace);
        config.setJournalDirectory(new File(dataPlace, "./journal").getAbsolutePath()).setPagingDirectory(new File(dataPlace, "./paging").getAbsolutePath()).setLargeMessagesDirectory(new File(dataPlace, "./largemessages").getAbsolutePath()).setBindingsDirectory(new File(dataPlace, "./bindings").getAbsolutePath()).setPersistenceEnabled(true);
        // disable server persistence since JORAM tests do not restart server
        server = ActiveMQServers.newActiveMQServer(config, useFiles);
        // set DLA and expiry to avoid spamming the log with warnings
        server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setDeadLetterAddress(SimpleString.toSimpleString("DLA")).setExpiryAddress(SimpleString.toSimpleString("Expiry")));
        serverManager = new JMSServerManagerImpl(server);
        serverManager.start();
    }
    return server;
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) Configuration(org.apache.activemq.artemis.core.config.Configuration) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) File(java.io.File)

Example 94 with Configuration

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

the class FailoverComplexClusterTest method commonSetup.

// default setup for most tests
private void commonSetup() throws Exception {
    Map<String, String> params = new HashMap<>();
    params.put("rebalanceClusterClients", "true");
    params.put("updateClusterClients", "true");
    params.put("updateClusterClientsOnRemove", "true");
    Configuration config0 = createConfig("localhost", 0, params);
    Configuration config1 = createConfig("localhost", 1, params);
    Configuration config2 = createConfig("localhost", 2, params);
    deployClusterConfiguration(config0, 1, 2);
    deployClusterConfiguration(config1, 0, 2);
    deployClusterConfiguration(config2, 0, 1);
    servers[0] = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    servers[1] = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    servers[2] = new EmbeddedJMS().setConfiguration(config2).setJmsConfiguration(new JMSConfigurationImpl());
    servers[0].start();
    servers[1].start();
    servers[2].start();
    Assert.assertTrue(servers[0].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 3));
    Assert.assertTrue(servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 3));
    Assert.assertTrue(servers[2].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 3));
}
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)

Example 95 with Configuration

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

the class FailoverComplexClusterTest method testFailOverWithUpdateClientsOnRemove.

@Test
public void testFailOverWithUpdateClientsOnRemove() throws Exception {
    // Broker A
    Configuration config0 = createConfig(0, "?rebalanceClusterClients=true&updateClusterClients=true&updateClusterClientsOnRemove=true");
    // Broker B
    Configuration config1 = createConfig(1, "?rebalanceClusterClients=true&updateClusterClients=true&updateClusterClientsOnRemove=true");
    deployClusterConfiguration(config0, 1);
    deployClusterConfiguration(config1, 0);
    servers[0] = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    servers[0].start();
    servers[1] = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    servers[1].start();
    servers[0].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2);
    servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2);
    Thread.sleep(1000);
    // create client connecting only to A. It should receive broker B address whet it connects to A.
    setClientUrl("failover:(" + BROKER_A_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=true");
    createClients(1);
    Thread.sleep(5000);
    // We stop broker A.
    servers[0].stop();
    servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 1);
    Thread.sleep(5000);
    // Client should failover to B.
    assertAllConnectedTo(BROKER_B_CLIENT_TC_ADDRESS);
}
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)

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