Search in sources :

Example 26 with Configuration

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

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

the class LoggingActiveMQServerPluginTest method createServerWithLoggingPlugin.

protected ActiveMQServer createServerWithLoggingPlugin(String loggingPluginEventType) throws Exception {
    // initial plugin
    LoggingActiveMQServerPlugin loggingActiveMQServerPlugin = new LoggingActiveMQServerPlugin();
    Map<String, String> properties = new HashMap<>();
    properties.put(loggingPluginEventType, "true");
    loggingActiveMQServerPlugin.init(properties);
    // register
    Configuration config = createDefaultConfig(true);
    config.registerBrokerPlugin(loggingActiveMQServerPlugin);
    return createServer(false, config);
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) LoggingActiveMQServerPlugin(org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin) HashMap(java.util.HashMap)

Example 28 with Configuration

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

the class ValidateAIOTest method testValidateAIO.

@Test
public void testValidateAIO() throws Exception {
    Configuration config = createDefaultInVMConfig().setJournalType(JournalType.ASYNCIO);
    ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, true));
    try {
        server.start();
    } finally {
        server.stop();
    }
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) Configuration(org.apache.activemq.artemis.core.config.Configuration) Test(org.junit.Test)

Example 29 with Configuration

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

the class DivertTest method testSingleDivertWithExpiry.

@Test
public void testSingleDivertWithExpiry() throws Exception {
    final String testAddress = "testAddress";
    final String forwardAddress = "forwardAddress";
    final String expiryAddress = "expiryAddress";
    AddressSettings expirySettings = new AddressSettings().setExpiryAddress(new SimpleString(expiryAddress));
    DivertConfiguration divertConf = new DivertConfiguration().setName("divert1").setRoutingName("divert1").setAddress(testAddress).setForwardingAddress(forwardAddress);
    Configuration config = createDefaultInVMConfig().addDivertConfiguration(divertConf).clearAddressesSettings().addAddressesSetting("#", expirySettings);
    ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, true));
    server.start();
    ServerLocator locator = createInVMNonHALocator();
    ClientSessionFactory sf = createSessionFactory(locator);
    ClientSession session = sf.createSession(false, false, false);
    final SimpleString queueName1 = new SimpleString("queue1");
    final SimpleString queueName2 = new SimpleString("queue2");
    session.createQueue(new SimpleString(forwardAddress), RoutingType.MULTICAST, queueName1, null, true);
    session.createQueue(new SimpleString(testAddress), RoutingType.MULTICAST, queueName2, null, true);
    session.createQueue(new SimpleString(expiryAddress), RoutingType.MULTICAST, new SimpleString(expiryAddress), null, true);
    session.start();
    ClientProducer producer = session.createProducer(new SimpleString(testAddress));
    ClientConsumer consumer1 = session.createConsumer(queueName1);
    ClientConsumer consumer2 = session.createConsumer(queueName2);
    final int numMessages = 1;
    final SimpleString propKey = new SimpleString("testkey");
    for (int i = 0; i < numMessages; i++) {
        ClientMessage message = session.createMessage(true);
        message.putIntProperty(propKey, i);
        message.setExpiration(System.currentTimeMillis() + 1000);
        producer.send(message);
    }
    session.commit();
    // this context is validating if these messages are routed correctly
    {
        int count1 = 0;
        ClientMessage message = null;
        while ((message = consumer1.receiveImmediate()) != null) {
            message.acknowledge();
            count1++;
        }
        int count2 = 0;
        while ((message = consumer2.receiveImmediate()) != null) {
            message.acknowledge();
            count2++;
        }
        assertEquals(1, count1);
        assertEquals(1, count2);
        session.rollback();
    }
    Thread.sleep(2000);
    // it must been expired by now
    assertNull(consumer1.receiveImmediate());
    // it must been expired by now
    assertNull(consumer2.receiveImmediate());
    int countOriginal1 = 0;
    int countOriginal2 = 0;
    ClientConsumer consumerExpiry = session.createConsumer(expiryAddress);
    for (int i = 0; i < numMessages * 2; i++) {
        ClientMessage message = consumerExpiry.receive(5000);
        System.out.println("Received message " + message);
        assertNotNull(message);
        if (message.getStringProperty(Message.HDR_ORIGINAL_QUEUE).equals("divert1")) {
            countOriginal1++;
        } else if (message.getStringProperty(Message.HDR_ORIGINAL_QUEUE).equals("queue2")) {
            countOriginal2++;
        } else {
            System.out.println("message not part of any expired queue" + message);
        }
    }
    assertEquals(numMessages, countOriginal1);
    assertEquals(numMessages, countOriginal2);
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) Configuration(org.apache.activemq.artemis.core.config.Configuration) DivertConfiguration(org.apache.activemq.artemis.core.config.DivertConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) DivertConfiguration(org.apache.activemq.artemis.core.config.DivertConfiguration) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) ClientConsumer(org.apache.activemq.artemis.api.core.client.ClientConsumer) ClientProducer(org.apache.activemq.artemis.api.core.client.ClientProducer) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) Test(org.junit.Test)

Example 30 with Configuration

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

the class DivertTest method testMultipleNonExclusiveDivert.

@Test
public void testMultipleNonExclusiveDivert() throws Exception {
    final String testAddress = "testAddress";
    final String forwardAddress1 = "forwardAddress1";
    final String forwardAddress2 = "forwardAddress2";
    final String forwardAddress3 = "forwardAddress3";
    DivertConfiguration divertConf1 = new DivertConfiguration().setName("divert1").setRoutingName("divert1").setAddress(testAddress).setForwardingAddress(forwardAddress1);
    DivertConfiguration divertConf2 = new DivertConfiguration().setName("divert2").setRoutingName("divert2").setAddress(testAddress).setForwardingAddress(forwardAddress2);
    DivertConfiguration divertConf3 = new DivertConfiguration().setName("divert3").setRoutingName("divert3").setAddress(testAddress).setForwardingAddress(forwardAddress3);
    Configuration config = createDefaultInVMConfig().addDivertConfiguration(divertConf1).addDivertConfiguration(divertConf2).addDivertConfiguration(divertConf3);
    ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, false));
    server.start();
    ServerLocator locator = createInVMNonHALocator();
    ClientSessionFactory sf = createSessionFactory(locator);
    ClientSession session = sf.createSession(false, true, true);
    final SimpleString queueName1 = new SimpleString("queue1");
    final SimpleString queueName2 = new SimpleString("queue2");
    final SimpleString queueName3 = new SimpleString("queue3");
    final SimpleString queueName4 = new SimpleString("queue4");
    session.createQueue(new SimpleString(forwardAddress1), RoutingType.MULTICAST, queueName1, null, false);
    session.createQueue(new SimpleString(forwardAddress2), RoutingType.MULTICAST, queueName2, null, false);
    session.createQueue(new SimpleString(forwardAddress3), RoutingType.MULTICAST, queueName3, null, false);
    session.createQueue(new SimpleString(testAddress), RoutingType.MULTICAST, queueName4, null, false);
    session.start();
    ClientProducer producer = session.createProducer(new SimpleString(testAddress));
    ClientConsumer consumer1 = session.createConsumer(queueName1);
    ClientConsumer consumer2 = session.createConsumer(queueName2);
    ClientConsumer consumer3 = session.createConsumer(queueName3);
    ClientConsumer consumer4 = session.createConsumer(queueName4);
    final int numMessages = 10;
    final SimpleString propKey = new SimpleString("testkey");
    for (int i = 0; i < numMessages; i++) {
        ClientMessage message = session.createMessage(false);
        message.putIntProperty(propKey, i);
        producer.send(message);
    }
    for (int i = 0; i < numMessages; i++) {
        ClientMessage message = consumer1.receive(DivertTest.TIMEOUT);
        Assert.assertNotNull(message);
        Assert.assertEquals(i, message.getIntProperty(propKey).intValue());
        message.acknowledge();
    }
    Assert.assertNull(consumer1.receiveImmediate());
    for (int i = 0; i < numMessages; i++) {
        ClientMessage message = consumer2.receive(DivertTest.TIMEOUT);
        Assert.assertNotNull(message);
        Assert.assertEquals(i, message.getIntProperty(propKey).intValue());
        message.acknowledge();
    }
    Assert.assertNull(consumer2.receiveImmediate());
    for (int i = 0; i < numMessages; i++) {
        ClientMessage message = consumer3.receive(DivertTest.TIMEOUT);
        Assert.assertNotNull(message);
        Assert.assertEquals(i, message.getIntProperty(propKey).intValue());
        message.acknowledge();
    }
    Assert.assertNull(consumer3.receiveImmediate());
    for (int i = 0; i < numMessages; i++) {
        ClientMessage message = consumer4.receive(DivertTest.TIMEOUT);
        Assert.assertNotNull(message);
        Assert.assertEquals(i, message.getIntProperty(propKey).intValue());
        message.acknowledge();
    }
    Assert.assertNull(consumer4.receiveImmediate());
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) Configuration(org.apache.activemq.artemis.core.config.Configuration) DivertConfiguration(org.apache.activemq.artemis.core.config.DivertConfiguration) DivertConfiguration(org.apache.activemq.artemis.core.config.DivertConfiguration) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) ClientConsumer(org.apache.activemq.artemis.api.core.client.ClientConsumer) ClientProducer(org.apache.activemq.artemis.api.core.client.ClientProducer) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) 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