Search in sources :

Example 56 with Configuration

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

the class HAPolicyConfigurationTest method SharedStoreSlaveTest2.

@Test
public void SharedStoreSlaveTest2() throws Exception {
    Configuration configuration = createConfiguration("shared-store-slave-hapolicy-config2.xml");
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    try {
        server.start();
        Activation activation = server.getActivation();
        assertTrue(activation instanceof SharedStoreBackupActivation);
        HAPolicy haPolicy = server.getHAPolicy();
        assertTrue(haPolicy instanceof SharedStoreSlavePolicy);
        SharedStoreSlavePolicy sharedStoreSlavePolicy = (SharedStoreSlavePolicy) haPolicy;
        assertTrue(sharedStoreSlavePolicy.isFailoverOnServerShutdown());
        assertTrue(sharedStoreSlavePolicy.isRestartBackup());
        ScaleDownPolicy scaleDownPolicy = sharedStoreSlavePolicy.getScaleDownPolicy();
        assertNotNull(scaleDownPolicy);
        assertEquals(scaleDownPolicy.getGroupName(), "boo!");
        assertEquals(scaleDownPolicy.getDiscoveryGroup(), null);
        List<String> connectors = scaleDownPolicy.getConnectors();
        assertNotNull(connectors);
        assertEquals(connectors.size(), 2);
        assertTrue(connectors.contains("sd-connector1"));
        assertTrue(connectors.contains("sd-connector2"));
    } finally {
        server.stop();
    }
}
Also used : SharedStoreSlavePolicy(org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy) Configuration(org.apache.activemq.artemis.core.config.Configuration) StoreConfiguration(org.apache.activemq.artemis.core.config.StoreConfiguration) HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) HAPolicy(org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy) SharedNothingBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation) ColocatedActivation(org.apache.activemq.artemis.core.server.impl.ColocatedActivation) Activation(org.apache.activemq.artemis.core.server.impl.Activation) SharedNothingLiveActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingLiveActivation) SharedStoreLiveActivation(org.apache.activemq.artemis.core.server.impl.SharedStoreLiveActivation) SharedStoreBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedStoreBackupActivation) LiveOnlyActivation(org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation) ScaleDownPolicy(org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) SharedStoreBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedStoreBackupActivation) Test(org.junit.Test)

Example 57 with Configuration

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

the class HAPolicyConfigurationTest method shouldNotUseJdbcNodeManagerWithoutHAPolicy.

@Test
public void shouldNotUseJdbcNodeManagerWithoutHAPolicy() throws Exception {
    Configuration configuration = createConfiguration("database-store-no-hapolicy-config.xml");
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    assertEquals(StoreConfiguration.StoreType.DATABASE, server.getConfiguration().getStoreConfiguration().getStoreType());
    assertEquals(HAPolicyConfiguration.TYPE.LIVE_ONLY, server.getConfiguration().getHAPolicyConfiguration().getType());
    try {
        server.start();
        assertThat(server.getNodeManager(), instanceOf(InVMNodeManager.class));
    } finally {
        server.stop();
    }
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) StoreConfiguration(org.apache.activemq.artemis.core.config.StoreConfiguration) HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) Test(org.junit.Test)

Example 58 with Configuration

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

the class SecurityManagementWithModifiedConfigurationTest method setupAndStartActiveMQServer.

// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
protected ActiveMQServer setupAndStartActiveMQServer() throws Exception {
    Configuration conf = createDefaultInVMConfig().setSecurityEnabled(true).setClusterPassword(configuredClusterPassword);
    ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(conf, false));
    server.start();
    return server;
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) Configuration(org.apache.activemq.artemis.core.config.Configuration) ActiveMQDefaultConfiguration(org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration)

Example 59 with Configuration

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

the class MQTTSecurityCRLTest method initServer.

private ActiveMQServer initServer() throws Exception {
    Configuration configuration = createDefaultNettyConfig().setSecurityEnabled(false);
    addMqttTransportConfiguration(configuration);
    addWildCardConfiguration(configuration);
    ActiveMQServer server = createServer(true, configuration);
    return server;
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) Configuration(org.apache.activemq.artemis.core.config.Configuration) WildcardConfiguration(org.apache.activemq.artemis.core.config.WildcardConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration)

Example 60 with Configuration

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

the class MQTTTest method testDoubleBroker.

@Test
public void testDoubleBroker() throws Exception {
    /*
       * Start two embedded server instances for MQTT and connect to them
       * with the same MQTT client id. As those are two different instances
       * connecting to them with the same client ID must succeed.
       */
    final int port1 = 1884;
    final int port2 = 1885;
    final Configuration cfg1 = createDefaultConfig(1, false);
    cfg1.addAcceptorConfiguration("mqtt1", "tcp://localhost:" + port1 + "?protocols=MQTT");
    final Configuration cfg2 = createDefaultConfig(2, false);
    cfg2.addAcceptorConfiguration("mqtt2", "tcp://localhost:" + port2 + "?protocols=MQTT");
    final ActiveMQServer server1 = createServer(cfg1);
    server1.start();
    final ActiveMQServer server2 = createServer(cfg2);
    server2.start();
    final String clientId = "client1";
    final MQTT mqtt1 = createMQTTConnection(clientId, true);
    final MQTT mqtt2 = createMQTTConnection(clientId, true);
    mqtt1.setHost("localhost", port1);
    mqtt2.setHost("localhost", port2);
    final BlockingConnection connection1 = mqtt1.blockingConnection();
    final BlockingConnection connection2 = mqtt2.blockingConnection();
    try {
        connection1.connect();
        connection2.connect();
    } catch (Exception e) {
        fail("Connections should have worked.");
    } finally {
        if (connection1.isConnected())
            connection1.disconnect();
        if (connection2.isConnected())
            connection2.disconnect();
    }
}
Also used : MQTT(org.fusesource.mqtt.client.MQTT) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) Configuration(org.apache.activemq.artemis.core.config.Configuration) CoreAddressConfiguration(org.apache.activemq.artemis.core.config.CoreAddressConfiguration) CoreQueueConfiguration(org.apache.activemq.artemis.core.config.CoreQueueConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) BlockingConnection(org.fusesource.mqtt.client.BlockingConnection) EOFException(java.io.EOFException) ProtocolException(java.net.ProtocolException) Test(org.junit.Test)

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