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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations