Search in sources :

Example 46 with AddressSettings

use of org.apache.activemq.artemis.core.settings.impl.AddressSettings 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 47 with AddressSettings

use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.

the class EmbeddedBrokerTestSupport method createConfig.

protected Configuration createConfig(final String hostAddress, final int serverID) throws Exception {
    ConfigurationImpl configuration = new ConfigurationImpl().setJMXManagementEnabled(false).setSecurityEnabled(false).setJournalMinFiles(2).setJournalFileSize(1000 * 1024).setJournalType(JournalType.NIO).setJournalDirectory(getJournalDir(serverID, false)).setBindingsDirectory(getBindingsDir(serverID, false)).setPagingDirectory(getPageDir(serverID, false)).setLargeMessagesDirectory(getLargeMessagesDir(serverID, false)).setJournalCompactMinFiles(0).setJournalCompactPercentage(0).setClusterPassword(CLUSTER_PASSWORD);
    configuration.addAddressesSetting("#", new AddressSettings().setAutoCreateJmsQueues(true).setAutoDeleteJmsQueues(true));
    configuration.addAcceptorConfiguration("netty", newURI(hostAddress, serverID));
    configuration.addConnectorConfiguration("netty-connector", newURI(hostAddress, serverID));
    return configuration;
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl)

Example 48 with AddressSettings

use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.

the class ArtemisBrokerBase method createServer.

protected final ActiveMQServer createServer(final boolean realFiles, final Configuration configuration, final int pageSize, final int maxAddressSize, final AddressFullMessagePolicy fullPolicy, final Map<String, AddressSettings> settings) {
    ActiveMQServer server = ActiveMQServers.newActiveMQServer(configuration, realFiles);
    if (settings != null) {
        for (Map.Entry<String, AddressSettings> setting : settings.entrySet()) {
            server.getAddressSettingsRepository().addMatch(setting.getKey(), setting.getValue());
        }
    }
    AddressSettings defaultSetting = new AddressSettings();
    defaultSetting.setPageSizeBytes(pageSize);
    defaultSetting.setMaxSizeBytes(maxAddressSize);
    defaultSetting.setAddressFullMessagePolicy(fullPolicy);
    server.getAddressSettingsRepository().addMatch("#", defaultSetting);
    return server;
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) Map(java.util.Map) HashMap(java.util.HashMap)

Example 49 with AddressSettings

use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.

the class OpenwireArtemisBaseTest method createConfig.

protected Configuration createConfig(final String hostAddress, final int serverID, Map<String, String> params) throws Exception {
    ConfigurationImpl configuration = new ConfigurationImpl().setJMXManagementEnabled(false).setSecurityEnabled(false).setJournalMinFiles(2).setJournalFileSize(1000 * 1024).setJournalType(JournalType.NIO).setJournalDirectory(getJournalDir(serverID, false)).setBindingsDirectory(getBindingsDir(serverID, false)).setPagingDirectory(getPageDir(serverID, false)).setLargeMessagesDirectory(getLargeMessagesDir(serverID, false)).setJournalCompactMinFiles(0).setJournalCompactPercentage(0).setClusterPassword(CLUSTER_PASSWORD);
    configuration.addAddressesSetting("#", new AddressSettings().setAutoCreateJmsQueues(true).setAutoDeleteJmsQueues(true));
    configuration.addAcceptorConfiguration("netty", newURI(hostAddress, serverID) + "?" + URISupport.createQueryString(params));
    configuration.addConnectorConfiguration("netty-connector", newURI(hostAddress, serverID));
    return configuration;
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl)

Example 50 with AddressSettings

use of org.apache.activemq.artemis.core.settings.impl.AddressSettings in project activemq-artemis by apache.

the class OpenwireArtemisBaseTest method createConfig.

// extraAcceptor takes form: "?name=value&name1=value ..."
protected Configuration createConfig(final int serverID, String extraAcceptorParams) throws Exception {
    ConfigurationImpl configuration = new ConfigurationImpl().setJMXManagementEnabled(false).setSecurityEnabled(false).setJournalMinFiles(2).setJournalFileSize(100 * 1024).setJournalType(JournalType.NIO).setJournalDirectory(getJournalDir(serverID, false)).setBindingsDirectory(getBindingsDir(serverID, false)).setPagingDirectory(getPageDir(serverID, false)).setLargeMessagesDirectory(getLargeMessagesDir(serverID, false)).setJournalCompactMinFiles(0).setJournalCompactPercentage(0).setClusterPassword(CLUSTER_PASSWORD);
    configuration.addAddressesSetting("#", new AddressSettings().setAutoCreateJmsQueues(true).setAutoDeleteJmsQueues(true));
    String fullAcceptorUri = newURI(serverID) + extraAcceptorParams;
    configuration.addAcceptorConfiguration("netty", fullAcceptorUri);
    configuration.addConnectorConfiguration("netty-connector", newURI(serverID));
    return configuration;
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl)

Aggregations

AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)273 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)162 Test (org.junit.Test)161 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)103 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)103 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)88 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)81 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)65 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)54 Configuration (org.apache.activemq.artemis.core.config.Configuration)52 HashMap (java.util.HashMap)31 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)30 Queue (org.apache.activemq.artemis.core.server.Queue)24 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)21 Before (org.junit.Before)19 Session (javax.jms.Session)18 Message (org.apache.activemq.artemis.api.core.Message)18 ArrayList (java.util.ArrayList)15 PagingStore (org.apache.activemq.artemis.core.paging.PagingStore)15 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)14