Search in sources :

Example 91 with AddressSettings

use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.

the class AbstractSendReceivePerfTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    jmsServer.createQueue(false, Q_NAME, null, true, Q_NAME);
    queue = ActiveMQJMSClient.createQueue(Q_NAME);
    AddressSettings settings = new AddressSettings().setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK).setMaxSizeBytes(Long.MAX_VALUE);
    server.getAddressSettingsRepository().clear();
    server.getAddressSettingsRepository().addMatch("#", settings);
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) Before(org.junit.Before)

Example 92 with AddressSettings

use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.

the class MeasurePagingMultiThreadTest method testPagingMultipleSenders.

@Test
public void testPagingMultipleSenders() throws Throwable {
    final int NUMBER_OF_THREADS = 18;
    final int NUMBER_OF_MESSAGES = 50000;
    final int SIZE_OF_MESSAGE = 1024;
    HashMap<String, AddressSettings> settings = new HashMap<>();
    ActiveMQServer messagingService = createServer(true, createDefaultInVMConfig(), 10 * 1024, 20 * 1024, settings);
    messagingService.start();
    ServerLocator locator = createInVMNonHALocator();
    try {
        final ClientSessionFactory factory = createSessionFactory(locator);
        final SimpleString adr = new SimpleString("test-adr");
        createDestination(factory, adr);
        // Send some messages to make sure the destination is in page mode before we measure
        // And that will also help with VM optimizations
        sendInitialBatch(adr, NUMBER_OF_MESSAGES, SIZE_OF_MESSAGE, factory);
        final CountDownLatch latchAlign = new CountDownLatch(NUMBER_OF_THREADS);
        final CountDownLatch latchStart = new CountDownLatch(1);
        class Sender extends Thread {

            private final ClientSession session;

            private final ClientProducer producer;

            private final ClientMessage msg;

            Throwable e;

            Sender() throws Exception {
                session = factory.createSession(false, true, true);
                producer = session.createProducer(adr);
                msg = session.createMessage(true);
                msg.getBodyBuffer().writeBytes(new byte[SIZE_OF_MESSAGE]);
            }

            // run is not going to close sessions or anything, as we don't want to measure that time
            // so this will be done in a second time
            public void cleanUp() throws Exception {
                session.close();
            }

            @Override
            public void run() {
                try {
                    latchAlign.countDown();
                    ActiveMQTestBase.waitForLatch(latchStart);
                    long start = System.currentTimeMillis();
                    sendMessages(NUMBER_OF_MESSAGES, producer, msg);
                    long end = System.currentTimeMillis();
                    System.out.println("Thread " + Thread.currentThread().getName() + " finished sending in " + (end - start) + " milliseconds");
                } catch (Throwable e) {
                    this.e = e;
                }
            }
        }
        Sender[] senders = new Sender[NUMBER_OF_THREADS];
        for (int i = 0; i < NUMBER_OF_THREADS; i++) {
            senders[i] = new Sender();
            senders[i].start();
        }
        ActiveMQTestBase.waitForLatch(latchAlign);
        long timeStart = System.currentTimeMillis();
        latchStart.countDown();
        for (Thread t : senders) {
            t.join();
        }
        long timeEnd = System.currentTimeMillis();
        System.out.println("Total Time: " + (timeEnd - timeStart) + " milliseconds what represented " + NUMBER_OF_MESSAGES * NUMBER_OF_THREADS * 1000 / (timeEnd - timeStart) + " per second");
        for (Sender s : senders) {
            if (s.e != null) {
                throw s.e;
            }
            s.cleanUp();
        }
    } finally {
        locator.close();
        messagingService.stop();
    }
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) HashMap(java.util.HashMap) 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) CountDownLatch(java.util.concurrent.CountDownLatch) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) ClientProducer(org.apache.activemq.artemis.api.core.client.ClientProducer) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) Test(org.junit.Test)

Example 93 with AddressSettings

use of org.apache.activemq.artemis.core.settings.impl.AddressSettings 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 AddressSettings

use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.

the class SymmetricClusterTest method testBasicRoundRobinManyMessagesNoAddressAutoCreate.

@Test
public void testBasicRoundRobinManyMessagesNoAddressAutoCreate() throws Exception {
    setupCluster();
    startServers();
    for (int i = 0; i < 5; i++) {
        servers[i].getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
    }
    for (int i = 0; i < 5; i++) {
        setupSessionFactory(i, isNetty());
    }
    for (int i = 0; i < 5; i++) {
        servers[i].addAddressInfo(new AddressInfo(SimpleString.toSimpleString("queues.testaddress"), RoutingType.MULTICAST));
        createQueue(i, "queues.testaddress", "queue0", null, false);
    }
    for (int i = 0; i < 5; i++) {
        addConsumer(i, i, "queue0", null);
    }
    for (int i = 0; i < 5; i++) {
        waitForBindings(i, "queues.testaddress", 1, 1, true);
    }
    for (int i = 0; i < 5; i++) {
        waitForBindings(i, "queues.testaddress", 4, 4, false);
    }
    send(0, "queues.testaddress", 1000, true, null);
    verifyReceiveRoundRobinInSomeOrder(1000, 0, 1, 2, 3, 4);
    verifyNotReceive(0, 1, 2, 3, 4);
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 95 with AddressSettings

use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.

the class TwoWayTwoNodeClusterTest method configureBeforeStart.

private void configureBeforeStart(Configuration... serverConfigs) {
    for (Configuration config : serverConfigs) {
        config.setPersistenceEnabled(true);
        config.setMessageCounterEnabled(true);
        config.setJournalFileSize(20971520);
        config.setJournalMinFiles(20);
        config.setJournalCompactPercentage(50);
        Map<String, AddressSettings> addressSettingsMap0 = config.getAddressesSettings();
        AddressSettings addrSettings = addressSettingsMap0.get("#");
        if (addrSettings == null) {
            addrSettings = new AddressSettings();
            addressSettingsMap0.put("#", addrSettings);
        }
        addrSettings.setDeadLetterAddress(new SimpleString("jms.queue.DLQ"));
        addrSettings.setExpiryAddress(new SimpleString("jms.queue.ExpiryQueue"));
        addrSettings.setRedeliveryDelay(30);
        addrSettings.setMaxDeliveryAttempts(5);
        addrSettings.setMaxSizeBytes(1048576);
        addrSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
        addrSettings.setPageSizeBytes(524288);
        addrSettings.setMessageCounterHistoryDayLimit(10);
        addrSettings.setRedistributionDelay(1000);
    }
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) Configuration(org.apache.activemq.artemis.core.config.Configuration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Aggregations

AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)273 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)162 Test (org.junit.Test)161 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)103 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)103 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)88 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)81 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)65 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)54 Configuration (org.apache.activemq.artemis.core.config.Configuration)52 HashMap (java.util.HashMap)31 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)30 Queue (org.apache.activemq.artemis.core.server.Queue)24 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)21 Before (org.junit.Before)19 Session (javax.jms.Session)18 Message (org.apache.activemq.artemis.api.core.Message)18 ArrayList (java.util.ArrayList)15 PagingStore (org.apache.activemq.artemis.core.paging.PagingStore)15 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)14