use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.
the class TwoWayTwoNodeClusterTest method testClusterRestartWithConfigChanged.
/*
* This test starts 2 servers and send messages to
* a queue until it enters into paging state. Then
* it changes the max-size to -1, restarts the 2 servers
* and consumes all the messages. If verifies that
* even if the max-size has changed all the paged
* messages will be depaged and consumed. No stuck
* messages after restarting.
*/
@Test(timeout = 60000)
public void testClusterRestartWithConfigChanged() throws Exception {
Configuration config0 = servers[0].getConfiguration();
Configuration config1 = servers[1].getConfiguration();
configureBeforeStart(config0, config1);
startServers(0, 1);
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
createQueue(0, "queues", "queue0", null, true);
createQueue(1, "queues", "queue0", null, true);
waitForBindings(0, "queues", 1, 0, true);
waitForBindings(1, "queues", 1, 0, true);
waitForBindings(0, "queues", 1, 0, false);
waitForBindings(1, "queues", 1, 0, false);
ClientSessionFactory sf0 = sfs[0];
ClientSession session0 = sf0.createSession(false, false);
ClientProducer producer = session0.createProducer("queues");
final int numSent = 200;
for (int i = 0; i < numSent; i++) {
ClientMessage msg = createTextMessage(session0, true, 5000);
producer.send(msg);
if (i % 50 == 0) {
session0.commit();
}
}
session0.commit();
session0.close();
while (true) {
long msgCount0 = getMessageCount(servers[0], "queues");
long msgCount1 = getMessageCount(servers[1], "queues");
if (msgCount0 + msgCount1 >= numSent) {
break;
}
Thread.sleep(100);
}
Queue queue0 = servers[0].locateQueue(new SimpleString("queue0"));
assertTrue(queue0.getPageSubscription().isPaging());
closeAllSessionFactories();
stopServers(0, 1);
AddressSettings addressSettings0 = config0.getAddressesSettings().get("#");
AddressSettings addressSettings1 = config1.getAddressesSettings().get("#");
addressSettings0.setMaxSizeBytes(-1);
addressSettings1.setMaxSizeBytes(-1);
startServers(0, 1);
waitForBindings(0, "queues", 1, 0, true);
waitForBindings(1, "queues", 1, 0, true);
waitForBindings(0, "queues", 1, 0, false);
waitForBindings(1, "queues", 1, 0, false);
setupSessionFactory(0, isNetty());
addConsumer(0, 0, "queue0", null);
waitForBindings(0, "queues", 1, 1, true);
for (int i = 0; i < numSent; i++) {
ClientMessage m = consumers[0].consumer.receive(5000);
assertNotNull("failed to receive message " + i, m);
}
}
use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.
the class StompTest method testSendMessageToNonExistentQueueUsingExplicitDefaultRouting.
@Test
public void testSendMessageToNonExistentQueueUsingExplicitDefaultRouting() throws Exception {
String nonExistentQueue = RandomUtil.randomString();
server.getActiveMQServer().getAddressSettingsRepository().addMatch(nonExistentQueue, new AddressSettings().setDefaultAddressRoutingType(RoutingType.ANYCAST).setDefaultQueueRoutingType(RoutingType.ANYCAST));
sendMessageToNonExistentQueue(getQueuePrefix(), nonExistentQueue, null);
}
use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.
the class StompTest method testAutoCreatedAnycastAddress.
@Test
public void testAutoCreatedAnycastAddress() throws Exception {
conn.connect(defUser, defPass);
String queueName = UUID.randomUUID().toString();
SimpleString simpleQueueName = SimpleString.toSimpleString(queueName);
ActiveMQServer activeMQServer = server.getActiveMQServer();
Assert.assertNull(activeMQServer.getAddressInfo(simpleQueueName));
Assert.assertNull(activeMQServer.locateQueue(simpleQueueName));
activeMQServer.getAddressSettingsRepository().addMatch(queueName, new AddressSettings().setDefaultAddressRoutingType(RoutingType.ANYCAST).setDefaultQueueRoutingType(RoutingType.ANYCAST));
send(conn, queueName, null, "Hello ANYCAST");
assertTrue("Address and queue should be created now", Wait.waitFor(() -> (activeMQServer.getAddressInfo(simpleQueueName) != null) && (activeMQServer.locateQueue(simpleQueueName) != null), 2000, 200));
assertTrue(activeMQServer.getAddressInfo(simpleQueueName).getRoutingTypes().contains(RoutingType.ANYCAST));
assertEquals(RoutingType.ANYCAST, activeMQServer.locateQueue(simpleQueueName).getRoutingType());
}
use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.
the class MultipliedDelayedMessageTest method initServer.
/**
* @throws Exception
*/
protected void initServer() throws Exception {
server = createServer(true, createDefaultInVMConfig());
server.start();
// Create settings to enable multiplied redelivery delay
AddressSettings addressSettings = server.getAddressSettingsRepository().getMatch("*");
AddressSettings newAddressSettings = new AddressSettings().setRedeliveryDelay(DELAY).setRedeliveryMultiplier(MULTIPLIER).setMaxRedeliveryDelay(MAX_DELAY);
newAddressSettings.merge(addressSettings);
server.getAddressSettingsRepository().addMatch(queueName, newAddressSettings);
locator = createInVMNonHALocator();
}
use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.
the class ScaleDownDirectTest method testPaging.
@Test
public void testPaging() throws Exception {
final int CHUNK_SIZE = 50;
int messageCount = 0;
final String addressName = "testAddress";
final String queueName = "testQueue";
createQueue(0, addressName, queueName, null, true);
createQueue(1, addressName, queueName, null, true);
ClientSessionFactory sf = sfs[0];
ClientSession session = addClientSession(sf.createSession(false, false));
ClientProducer producer = addClientProducer(session.createProducer(addressName));
AddressSettings defaultSetting = new AddressSettings().setPageSizeBytes(10 * 1024).setMaxSizeBytes(20 * 1024);
servers[0].getAddressSettingsRepository().addMatch("#", defaultSetting);
while (!servers[0].getPagingManager().getPageStore(new SimpleString(addressName)).isPaging()) {
for (int i = 0; i < CHUNK_SIZE; i++) {
Message message = session.createMessage(true);
message.getBodyBuffer().writeBytes(new byte[1024]);
// The only purpose of this count here is for eventually debug messages on print-data / print-pages
// message.putIntProperty("count", messageCount);
producer.send(message);
messageCount++;
}
session.commit();
}
assertEquals(messageCount, performScaledown());
servers[0].stop();
addConsumer(0, 1, queueName, null);
for (int i = 0; i < messageCount; i++) {
ClientMessage message = consumers[0].getConsumer().receive(500);
Assert.assertNotNull(message);
// Assert.assertEquals(i, message.getIntProperty("count").intValue());
}
Assert.assertNull(consumers[0].getConsumer().receiveImmediate());
removeConsumer(0);
}
Aggregations