use of org.apache.activemq.artemis.core.registry.JndiBindingRegistry in project activemq-artemis by apache.
the class FailureDeadlockTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
server = createServer(false, createDefaultInVMConfig());
jmsServer = new JMSServerManagerImpl(server);
jmsServer.setRegistry(new JndiBindingRegistry(new NullInitialContext()));
jmsServer.start();
cf1 = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
cf2 = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
}
use of org.apache.activemq.artemis.core.registry.JndiBindingRegistry 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.registry.JndiBindingRegistry in project activemq-artemis by apache.
the class FloodServerTest method setUp.
// Static --------------------------------------------------------
// Attributes ----------------------------------------------------
// Constructors --------------------------------------------------
// TestCase overrides -------------------------------------------
// Public --------------------------------------------------------
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
super.setUp();
Configuration config = createDefaultNettyConfig();
server = addServer(ActiveMQServers.newActiveMQServer(config, false));
server.start();
serverManager = new JMSServerManagerImpl(server);
initialContext = new InVMNamingContext();
serverManager.setRegistry(new JndiBindingRegistry(initialContext));
serverManager.start();
serverManager.activated();
serverManager.createTopic(false, topicName, topicName);
registerConnectionFactory();
}
use of org.apache.activemq.artemis.core.registry.JndiBindingRegistry in project activemq-artemis by apache.
the class OpenWireTestBase method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
server = this.createServer(realStore, true);
Configuration serverConfig = server.getConfiguration();
serverConfig.getAddressesSettings().put("#", new AddressSettings().setAutoCreateQueues(false).setAutoCreateAddresses(false).setDeadLetterAddress(new SimpleString("ActiveMQ.DLQ")).setAutoCreateAddresses(true));
serverConfig.setSecurityEnabled(enableSecurity);
extraServerConfig(serverConfig);
if (enableSecurity) {
ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
securityManager.getConfiguration().addRole("openwireSender", "sender");
securityManager.getConfiguration().addUser("openwireSender", "SeNdEr");
// sender cannot receive
Role senderRole = new Role("sender", true, false, false, false, true, true, false, false, true, true);
securityManager.getConfiguration().addRole("openwireReceiver", "receiver");
securityManager.getConfiguration().addUser("openwireReceiver", "ReCeIvEr");
// receiver cannot send
Role receiverRole = new Role("receiver", false, true, false, false, true, true, false, true, false, false);
securityManager.getConfiguration().addRole("openwireGuest", "guest");
securityManager.getConfiguration().addUser("openwireGuest", "GuEsT");
// guest cannot do anything
Role guestRole = new Role("guest", false, false, false, false, false, false, false, false, false, false);
securityManager.getConfiguration().addRole("openwireDestinationManager", "manager");
securityManager.getConfiguration().addUser("openwireDestinationManager", "DeStInAtIoN");
Role destRole = new Role("manager", false, false, false, false, true, true, false, false, false, false);
Set<Role> roles = new HashSet<>();
roles.add(senderRole);
roles.add(receiverRole);
roles.add(guestRole);
roles.add(destRole);
server.getConfiguration().putSecurityRoles("#", roles);
}
mbeanServer = MBeanServerFactory.createMBeanServer();
server.setMBeanServer(mbeanServer);
addServer(server);
jmsServer = new JMSServerManagerImpl(server);
namingContext = new InVMNamingContext();
jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
jmsServer.start();
registerConnectionFactory();
System.out.println("debug: server started");
}
use of org.apache.activemq.artemis.core.registry.JndiBindingRegistry in project activemq-artemis by apache.
the class JMSFailoverTest method startServers.
/**
* @throws Exception
*/
protected void startServers() throws Exception {
final boolean sharedStore = true;
NodeManager nodeManager = new InVMNodeManager(!sharedStore);
backuptc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, backupParams);
livetc = new TransportConfiguration(INVM_CONNECTOR_FACTORY);
liveAcceptortc = new TransportConfiguration(INVM_ACCEPTOR_FACTORY);
backupAcceptortc = new TransportConfiguration(INVM_ACCEPTOR_FACTORY, backupParams);
backupParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
backupConf = createBasicConfig().addAcceptorConfiguration(backupAcceptortc).addConnectorConfiguration(livetc.getName(), livetc).addConnectorConfiguration(backuptc.getName(), backuptc).setSecurityEnabled(false).setJournalType(getDefaultJournalType()).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, backupParams)).setBindingsDirectory(getBindingsDir()).setJournalMinFiles(2).setJournalDirectory(getJournalDir()).setPagingDirectory(getPageDir()).setLargeMessagesDirectory(getLargeMessagesDir()).setPersistenceEnabled(true).setHAPolicyConfiguration(sharedStore ? new SharedStoreSlavePolicyConfiguration() : new ReplicaPolicyConfiguration()).addClusterConfiguration(basicClusterConnectionConfig(backuptc.getName(), livetc.getName()));
backupServer = addServer(new InVMNodeManagerServer(backupConf, nodeManager));
backupJMSServer = new JMSServerManagerImpl(backupServer);
backupJMSServer.setRegistry(new JndiBindingRegistry(ctx2));
backupJMSServer.getActiveMQServer().setIdentity("JMSBackup");
log.info("Starting backup");
backupJMSServer.start();
liveConf = createBasicConfig().setJournalDirectory(getJournalDir()).setBindingsDirectory(getBindingsDir()).setSecurityEnabled(false).addAcceptorConfiguration(liveAcceptortc).setJournalType(getDefaultJournalType()).setBindingsDirectory(getBindingsDir()).setJournalMinFiles(2).setJournalDirectory(getJournalDir()).setPagingDirectory(getPageDir()).setLargeMessagesDirectory(getLargeMessagesDir()).addConnectorConfiguration(livetc.getName(), livetc).setPersistenceEnabled(true).setHAPolicyConfiguration(sharedStore ? new SharedStoreMasterPolicyConfiguration() : new ReplicatedPolicyConfiguration()).addClusterConfiguration(basicClusterConnectionConfig(livetc.getName()));
liveServer = addServer(new InVMNodeManagerServer(liveConf, nodeManager));
liveJMSServer = new JMSServerManagerImpl(liveServer);
liveJMSServer.setRegistry(new JndiBindingRegistry(ctx1));
liveJMSServer.getActiveMQServer().setIdentity("JMSLive");
log.info("Starting life");
liveJMSServer.start();
JMSUtil.waitForServer(backupServer);
}
Aggregations