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);
}
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();
}
}
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;
}
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);
}
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);
}
}
Aggregations