Search in sources :

Example 66 with Configuration

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());
}
Also used : ManagementServiceImpl(org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl) AddressControl(org.apache.activemq.artemis.api.core.management.AddressControl) NullStorageManager(org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager) FakeStorageManager(org.apache.activemq.artemis.tests.integration.server.FakeStorageManager) Configuration(org.apache.activemq.artemis.core.config.Configuration) FakeQueue(org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Queue(org.apache.activemq.artemis.core.server.Queue) FakeQueue(org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue) QueueControl(org.apache.activemq.artemis.api.core.management.QueueControl) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 67 with Configuration

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();
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) Configuration(org.apache.activemq.artemis.core.config.Configuration) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) Before(org.junit.Before)

Example 68 with Configuration

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();
}
Also used : DivertConfiguration(org.apache.activemq.artemis.core.config.DivertConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) Before(org.junit.Before)

Example 69 with Configuration

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);
    }
}
Also used : ActiveMQServerControl(org.apache.activemq.artemis.api.core.management.ActiveMQServerControl) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) HashMap(java.util.HashMap) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) JsonObject(javax.json.JsonObject) 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) InVMAcceptorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator)

Example 70 with Configuration

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);
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) ActiveMQDefaultConfiguration(org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration) Before(org.junit.Before)

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