Search in sources :

Example 21 with Configuration

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

the class LargeMessageTest method testPageOnLargeMessage.

protected void testPageOnLargeMessage(final boolean realFiles, final boolean sendBlocking) throws Exception {
    Configuration config = createDefaultConfig(isNetty());
    final int PAGE_MAX = 20 * 1024;
    final int PAGE_SIZE = 10 * 1024;
    HashMap<String, AddressSettings> map = new HashMap<>();
    AddressSettings value = new AddressSettings();
    map.put(ADDRESS.toString(), value);
    ActiveMQServer server = createServer(realFiles, config, PAGE_SIZE, PAGE_MAX, map, storeType);
    server.start();
    final int numberOfBytes = 1024;
    final int numberOfBytesBigMessage = 400000;
    ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator));
    if (sendBlocking) {
        sf.getServerLocator().setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setBlockOnAcknowledge(true);
    }
    ClientSession session = sf.createSession(null, null, false, true, true, false, 0);
    session.createQueue(ADDRESS, ADDRESS, null, true);
    ClientProducer producer = session.createProducer(ADDRESS);
    ClientMessage message = null;
    for (int i = 0; i < 100; i++) {
        message = session.createMessage(true);
        // TODO: Why do I need to reset the writerIndex?
        message.getBodyBuffer().writerIndex(0);
        for (int j = 1; j <= numberOfBytes; j++) {
            message.getBodyBuffer().writeInt(j);
        }
        producer.send(message);
    }
    ClientMessage clientFile = createLargeClientMessageStreaming(session, numberOfBytesBigMessage);
    producer.send(clientFile);
    session.close();
    if (realFiles) {
        server.stop();
        server = createServer(true, config, PAGE_SIZE, PAGE_MAX, map, storeType);
        server.start();
        sf = createSessionFactory(locator);
    }
    session = sf.createSession(null, null, false, true, true, false, 0);
    ClientConsumer consumer = session.createConsumer(ADDRESS);
    session.start();
    for (int i = 0; i < 100; i++) {
        ClientMessage message2 = consumer.receive(LargeMessageTest.RECEIVE_WAIT_TIME);
        Assert.assertNotNull(message2);
        message2.acknowledge();
        Assert.assertNotNull(message2);
        message.getBodyBuffer().readerIndex(0);
        for (int j = 1; j <= numberOfBytes; j++) {
            Assert.assertEquals(j, message.getBodyBuffer().readInt());
        }
    }
    consumer.close();
    session.close();
    session = sf.createSession(null, null, false, true, true, false, 0);
    readMessage(session, ADDRESS, numberOfBytesBigMessage);
    // printBuffer("message received : ", message2.getBody());
    session.close();
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) Configuration(org.apache.activemq.artemis.core.config.Configuration) StoreConfiguration(org.apache.activemq.artemis.core.config.StoreConfiguration) HashMap(java.util.HashMap) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) ClientConsumer(org.apache.activemq.artemis.api.core.client.ClientConsumer) ClientProducer(org.apache.activemq.artemis.api.core.client.ClientProducer)

Example 22 with Configuration

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

the class MessageGroupingTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration configuration = createDefaultInVMConfig();
    server = addServer(ActiveMQServers.newActiveMQServer(configuration, false));
    server.start();
    locator = createInVMNonHALocator();
    clientSessionFactory = createSessionFactory(locator);
    clientSession = addClientSession(clientSessionFactory.createSession(false, true, true));
    clientSession.createQueue(qName, qName, null, false);
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) Before(org.junit.Before)

Example 23 with Configuration

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

the class ConcurrentCreateDeleteProduceTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration config = createDefaultInVMConfig().setJournalSyncNonTransactional(false).setJournalSyncTransactional(false);
    server = createServer(true, config, PAGE_SIZE, PAGE_MAX, new HashMap<String, AddressSettings>());
    server.start();
    locator = createNonHALocator(false).setBlockOnDurableSend(false).setBlockOnAcknowledge(true);
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) HashMap(java.util.HashMap) Before(org.junit.Before)

Example 24 with Configuration

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

the class ArtemisBrokerWrapper method start.

@Override
public void start() throws Exception {
    clearDataRecreateServerDirs();
    mbeanServer = MBeanServerFactory.createMBeanServer();
    server = createServer(realStore, true);
    server.setMBeanServer(mbeanServer);
    server.getConfiguration().getAcceptorConfigurations().clear();
    Configuration serverConfig = server.getConfiguration();
    serverConfig.setJMXManagementEnabled(true);
    Map<String, AddressSettings> addressSettingsMap = serverConfig.getAddressesSettings();
    // do policy translation
    PolicyMap policyMap = this.bservice.getDestinationPolicy();
    if (policyMap != null) {
        translatePolicyMap(serverConfig, policyMap);
    }
    String match = "#";
    AddressSettings commonSettings = addressSettingsMap.get(match);
    if (commonSettings == null) {
        commonSettings = new AddressSettings();
        addressSettingsMap.put(match, commonSettings);
    }
    SimpleString dla = new SimpleString("ActiveMQ.DLQ");
    commonSettings.setDeadLetterAddress(dla);
    commonSettings.setExpiryAddress(dla);
    commonSettings.setAutoCreateQueues(true);
    commonSettings.setAutoCreateAddresses(true);
    if (bservice.extraConnectors.size() == 0) {
        serverConfig.addAcceptorConfiguration("home", "tcp://localhost:61616");
    }
    for (BrokerService.ConnectorInfo info : bservice.extraConnectors) {
        addServerAcceptor(serverConfig, info);
    }
    serverConfig.setSecurityEnabled(enableSecurity);
    if (enableSecurity) {
        ActiveMQJAASSecurityManager sm = (ActiveMQJAASSecurityManager) server.getSecurityManager();
        SecurityConfiguration securityConfig = sm.getConfiguration();
        securityConfig.addRole("openwireSender", "sender");
        securityConfig.addUser("openwireSender", "SeNdEr");
        // sender cannot receive
        Role senderRole = new Role("sender", true, false, false, false, true, true, false, false);
        securityConfig.addRole("openwireReceiver", "receiver");
        securityConfig.addUser("openwireReceiver", "ReCeIvEr");
        // receiver cannot send
        Role receiverRole = new Role("receiver", false, true, false, false, true, true, false, true);
        securityConfig.addRole("openwireGuest", "guest");
        securityConfig.addUser("openwireGuest", "GuEsT");
        // guest cannot do anything
        Role guestRole = new Role("guest", false, false, false, false, false, false, false, false);
        securityConfig.addRole("openwireDestinationManager", "manager");
        securityConfig.addUser("openwireDestinationManager", "DeStInAtIoN");
        // manager can only manage
        Role destRole = new Role("manager", false, false, false, false, true, true, false, false);
        Map<String, Set<Role>> settings = server.getConfiguration().getSecurityRoles();
        if (settings == null) {
            settings = new HashMap<>();
            server.getConfiguration().setSecurityRoles(settings);
        }
        Set<Role> anySet = settings.get("#");
        if (anySet == null) {
            anySet = new HashSet<>();
            settings.put("#", anySet);
        }
        anySet.add(senderRole);
        anySet.add(receiverRole);
        anySet.add(guestRole);
        anySet.add(destRole);
    }
    Set<TransportConfiguration> acceptors = serverConfig.getAcceptorConfigurations();
    Iterator<TransportConfiguration> iter = acceptors.iterator();
    while (iter.hasNext()) {
        System.out.println("acceptor =>: " + iter.next());
    }
    jmsServer = new JMSServerManagerImpl(server);
    InVMNamingContext namingContext = new InVMNamingContext();
    jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
    jmsServer.start();
    server.start();
    stopped = false;
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) HashSet(java.util.HashSet) Set(java.util.Set) Configuration(org.apache.activemq.artemis.core.config.Configuration) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Role(org.apache.activemq.artemis.core.security.Role) PolicyMap(org.apache.activemq.broker.region.policy.PolicyMap) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) BrokerService(org.apache.activemq.broker.BrokerService)

Example 25 with Configuration

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

the class OpenwireArtemisBaseTest method createBroker.

public EmbeddedJMS createBroker() throws Exception {
    Configuration config0 = createConfig(0);
    EmbeddedJMS newbroker = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    return newbroker;
}
Also used : 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)

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