Search in sources :

Example 11 with Configuration

use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.

the class ZeroPrefetchConsumerTest method createArtemisBroker.

@Override
public EmbeddedJMS createArtemisBroker() throws Exception {
    Configuration config0 = createConfig("localhost", 0);
    String coreQueueAddress = brokerZeroQueue.getQueueName();
    AddressSettings addrSettings = new AddressSettings();
    addrSettings.setQueuePrefetch(0);
    config0.getAddressesSettings().put(coreQueueAddress, addrSettings);
    EmbeddedJMS newbroker = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    return newbroker;
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) EmbeddedJMS(org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS) Configuration(org.apache.activemq.artemis.core.config.Configuration) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl)

Example 12 with Configuration

use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.

the class ConsumerCloseTest method setUp.

// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration config = createDefaultInVMConfig();
    server = addServer(ActiveMQServers.newActiveMQServer(config, false));
    server.start();
    address = RandomUtil.randomSimpleString();
    queue = RandomUtil.randomSimpleString();
    locator = createInVMNonHALocator();
    sf = createSessionFactory(locator);
    session = addClientSession(sf.createSession(false, true, true));
    session.createQueue(address, queue, false);
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) Before(org.junit.Before)

Example 13 with Configuration

use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.

the class QueueAutoCreationTest method configureAddressPolicy.

@Override
protected void configureAddressPolicy(ActiveMQServer server) {
    Configuration serverConfig = server.getConfiguration();
    serverConfig.setJournalType(JournalType.NIO);
    Map<String, AddressSettings> map = serverConfig.getAddressesSettings();
    if (map.size() == 0) {
        AddressSettings as = new AddressSettings();
        map.put("#", as);
    }
    Map.Entry<String, AddressSettings> entry = map.entrySet().iterator().next();
    AddressSettings settings = entry.getValue();
    settings.setAutoCreateQueues(true);
    System.out.println("server cofg, isauto? " + entry.getValue().isAutoCreateQueues());
}
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) Map(java.util.Map)

Example 14 with Configuration

use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.

the class HangConsumerTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration config = createDefaultInVMConfig().setMessageExpiryScanPeriod(10);
    ActiveMQSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
    server = addServer(new MyActiveMQServer(config, ManagementFactory.getPlatformMBeanServer(), securityManager));
    server.start();
    locator = createInVMNonHALocator();
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) InVMLoginModule(org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) ActiveMQSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager) Before(org.junit.Before)

Example 15 with Configuration

use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.

the class HeuristicXATest method internalTest.

private void internalTest(final boolean isCommit) throws Exception {
    Configuration configuration = createDefaultInVMConfig().setJMXManagementEnabled(true);
    ActiveMQServer server = createServer(false, configuration);
    server.setMBeanServer(mbeanServer);
    server.start();
    Xid xid = newXID();
    ClientSessionFactory sf = createSessionFactory(locator);
    ClientSession session = sf.createSession(true, false, false);
    session.createQueue(ADDRESS, ADDRESS, true);
    session.start(xid, XAResource.TMNOFLAGS);
    ClientProducer producer = session.createProducer(ADDRESS);
    ClientMessage msg = session.createMessage(true);
    msg.getBodyBuffer().writeString(body);
    producer.send(msg);
    session.end(xid, XAResource.TMSUCCESS);
    session.prepare(xid);
    session.close();
    ActiveMQServerControl jmxServer = ManagementControlHelper.createActiveMQServerControl(mbeanServer);
    String[] preparedTransactions = jmxServer.listPreparedTransactions();
    Assert.assertEquals(1, preparedTransactions.length);
    System.out.println(preparedTransactions[0]);
    Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length);
    Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length);
    if (isCommit) {
        jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
    } else {
        jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
    }
    Assert.assertEquals(0, jmxServer.listPreparedTransactions().length);
    if (isCommit) {
        Assert.assertEquals(1, jmxServer.listHeuristicCommittedTransactions().length);
        Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length);
    } else {
        Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length);
        Assert.assertEquals(1, jmxServer.listHeuristicRolledBackTransactions().length);
    }
    if (isCommit) {
        Assert.assertEquals(1, getMessageCount(((Queue) server.getPostOffice().getBinding(ADDRESS).getBindable())));
        session = sf.createSession(false, false, false);
        session.start();
        ClientConsumer consumer = session.createConsumer(ADDRESS);
        msg = consumer.receive(1000);
        Assert.assertNotNull(msg);
        msg.acknowledge();
        Assert.assertEquals(body, msg.getBodyBuffer().readString());
        session.commit();
        session.close();
    }
    Assert.assertEquals(0, getMessageCount(((Queue) server.getPostOffice().getBinding(ADDRESS).getBindable())));
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) Xid(javax.transaction.xa.Xid) ActiveMQServerControl(org.apache.activemq.artemis.api.core.management.ActiveMQServerControl) Configuration(org.apache.activemq.artemis.core.config.Configuration) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ClientConsumer(org.apache.activemq.artemis.api.core.client.ClientConsumer) ClientProducer(org.apache.activemq.artemis.api.core.client.ClientProducer)

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