Search in sources :

Example 41 with JMSConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl in project activemq-artemis by apache.

the class FailoverPriorityTest method testPriorityBackupList.

@Test
public void testPriorityBackupList() 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&priorityURIs=tcp://127.0.0.1:61617&initialReconnectDelay=1000&useExponentialBackOff=false");
    createClients(5);
    Thread.sleep(3000);
    assertAllConnectedTo(urls.get(1));
    restart(false, 1, 0);
    for (int i = 0; i < 3; i++) {
        restart(true, 1, 0);
    }
    restart(false, 1, 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 42 with JMSConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl in project activemq-artemis by apache.

the class FailoverPriorityTest method testPriorityBackup.

@Test
public void testPriorityBackup() 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);
    assertAllConnectedTo(urls.get(0));
    restart(false, 0, 1);
    for (int i = 0; i < 3; i++) {
        restart(true, 0, 1);
    }
    Thread.sleep(5000);
    restart(false, 0, 1);
}
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 43 with JMSConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl in project activemq-artemis by apache.

the class FailoverPriorityTest method setupThreeBrokers.

private void setupThreeBrokers() throws Exception {
    params.put("rebalanceClusterClients", "false");
    params.put("updateClusterClients", "false");
    params.put("updateClusterClientsOnRemove", "false");
    Configuration config0 = createConfig("127.0.0.1", 0, params);
    Configuration config1 = createConfig("127.0.0.1", 1, params);
    Configuration config2 = createConfig("127.0.0.1", 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) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl)

Example 44 with JMSConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl in project activemq-artemis by apache.

the class FailoverTimeoutTest method testTimeout.

@Test
public void testTimeout() throws Exception {
    long timeout = 1000;
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + tcpUri + ")?timeout=" + timeout + "&useExponentialBackOff=false");
    Connection connection = cf.createConnection();
    try {
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = session.createProducer(session.createQueue(QUEUE_NAME));
        TextMessage message = session.createTextMessage("Test message");
        producer.send(message);
        server.stop();
        try {
            producer.send(message);
        } catch (JMSException jmse) {
            assertEquals("Failover timeout of " + timeout + " ms reached.", jmse.getMessage());
        }
        Configuration config = createConfig(0);
        server = new EmbeddedJMS().setConfiguration(config).setJmsConfiguration(new JMSConfigurationImpl());
        server.start();
        producer.send(message);
        server.stop();
        server = null;
    } finally {
        if (connection != null) {
            connection.close();
        }
    }
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) EmbeddedJMS(org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS) Configuration(org.apache.activemq.artemis.core.config.Configuration) Connection(javax.jms.Connection) ActiveMQConnection(org.apache.activemq.ActiveMQConnection) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) JMSException(javax.jms.JMSException) MessageProducer(javax.jms.MessageProducer) TextMessage(javax.jms.TextMessage) Session(javax.jms.Session) Test(org.junit.Test) OpenwireArtemisBaseTest(org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest)

Example 45 with JMSConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl in project activemq-artemis by apache.

the class FanoutTransportBrokerTest method setUp.

@Before
public void setUp() throws Exception {
    Configuration config0 = createConfig(0);
    server = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    Configuration config1 = createConfig(1);
    remoteServer = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    server.start();
    remoteServer.start();
}
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

JMSConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl)62 Configuration (org.apache.activemq.artemis.core.config.Configuration)57 EmbeddedJMS (org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS)52 Before (org.junit.Before)19 Test (org.junit.Test)16 OpenwireArtemisBaseTest (org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest)14 HashMap (java.util.HashMap)10 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)8 JMSConfiguration (org.apache.activemq.artemis.jms.server.config.JMSConfiguration)8 MessageProducer (javax.jms.MessageProducer)6 Queue (javax.jms.Queue)6 Session (javax.jms.Session)6 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)6 JndiBindingRegistry (org.apache.activemq.artemis.core.registry.JndiBindingRegistry)6 JMSServerManagerImpl (org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl)6 InVMNamingContext (org.apache.activemq.artemis.tests.unit.util.InVMNamingContext)6 ConnectionFactoryConfiguration (org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration)5 JMSQueueConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl)5 URI (java.net.URI)4 Connection (javax.jms.Connection)4