use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class ManagementServiceImplTest method testGetResources.
@Test
public void testGetResources() throws Exception {
Configuration config = createBasicConfig().setJMXManagementEnabled(false);
ManagementServiceImpl managementService = new ManagementServiceImpl(null, config);
managementService.setStorageManager(new NullStorageManager());
SimpleString address = RandomUtil.randomSimpleString();
managementService.registerAddress(new AddressInfo(address));
Queue queue = new FakeQueue(RandomUtil.randomSimpleString());
managementService.registerQueue(queue, RandomUtil.randomSimpleString(), new FakeStorageManager());
Object[] addresses = managementService.getResources(AddressControl.class);
Assert.assertEquals(1, addresses.length);
Assert.assertTrue(addresses[0] instanceof AddressControl);
AddressControl addressControl = (AddressControl) addresses[0];
Assert.assertEquals(address.toString(), addressControl.getAddress());
Object[] queues = managementService.getResources(QueueControl.class);
Assert.assertEquals(1, queues.length);
Assert.assertTrue(queues[0] instanceof QueueControl);
QueueControl queueControl = (QueueControl) queues[0];
Assert.assertEquals(queue.getName().toString(), queueControl.getName());
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class ManagementWithPagingServerTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
Configuration config = createDefaultInVMConfig().setJMXManagementEnabled(true);
server = addServer(ActiveMQServers.newActiveMQServer(config, mbeanServer, true));
AddressSettings defaultSetting = new AddressSettings().setPageSizeBytes(5120).setMaxSizeBytes(10240).setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
server.getAddressSettingsRepository().addMatch("#", defaultSetting);
server.start();
locator = createInVMNonHALocator().setBlockOnNonDurableSend(false).setConsumerWindowSize(0);
ClientSessionFactory sf = createSessionFactory(locator);
session1 = sf.createSession(false, true, false);
session1.start();
session2 = sf.createSession(false, true, false);
session2.start();
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class QueueControlTest method setUp.
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
super.setUp();
Configuration conf = createDefaultInVMConfig().setJMXManagementEnabled(true);
server = addServer(ActiveMQServers.newActiveMQServer(conf, mbeanServer, false));
server.start();
locator = createInVMNonHALocator().setBlockOnNonDurableSend(true).setConsumerWindowSize(0);
ClientSessionFactory sf = createSessionFactory(locator);
session = sf.createSession(false, true, false);
session.start();
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class ActiveMQServerControlTest method scaleDown.
protected void scaleDown(ScaleDownHandler handler) throws Exception {
SimpleString address = new SimpleString("testQueue");
HashMap<String, Object> params = new HashMap<>();
params.put(TransportConstants.SERVER_ID_PROP_NAME, "2");
Configuration config = createDefaultInVMConfig(2).clearAcceptorConfigurations().addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName(), params)).setSecurityEnabled(false);
ActiveMQServer server2 = addServer(ActiveMQServers.newActiveMQServer(config, null, true));
this.conf.clearConnectorConfigurations().addConnectorConfiguration("server2-connector", new TransportConfiguration(INVM_CONNECTOR_FACTORY, params));
server2.start();
server.addAddressInfo(new AddressInfo(address, RoutingType.ANYCAST));
server.createQueue(address, RoutingType.ANYCAST, address, null, true, false, -1, false, false);
server2.addAddressInfo(new AddressInfo(address, RoutingType.ANYCAST));
server2.createQueue(address, RoutingType.ANYCAST, address, null, true, false, -1, false, false);
ServerLocator locator = createInVMNonHALocator();
ClientSessionFactory csf = createSessionFactory(locator);
ClientSession session = csf.createSession();
ClientProducer producer = session.createProducer(address);
for (int i = 0; i < 100; i++) {
ClientMessage message = session.createMessage(true);
message.getBodyBuffer().writeString("m" + i);
producer.send(message);
}
ActiveMQServerControl managementControl = createManagementControl();
handler.scaleDown(managementControl);
locator.close();
locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(INVM_CONNECTOR_FACTORY, params)));
csf = createSessionFactory(locator);
session = csf.createSession();
session.start();
ClientConsumer consumer = session.createConsumer(address);
for (int i = 0; i < 100; i++) {
ClientMessage m = consumer.receive(5000);
assertNotNull(m);
}
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class AddressControlTest method setUp.
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
super.setUp();
Configuration config = createDefaultInVMConfig().setJMXManagementEnabled(true);
server = createServer(false, config);
server.setMBeanServer(mbeanServer);
server.start();
locator = createInVMNonHALocator().setBlockOnNonDurableSend(true);
sf = createSessionFactory(locator);
session = sf.createSession(false, true, false);
session.start();
addClientSession(session);
}
Aggregations