Search in sources :

Example 1 with JndiBindingRegistry

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));
}
Also used : JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) NullInitialContext(org.apache.activemq.artemis.tests.integration.jms.server.management.NullInitialContext) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Before(org.junit.Before)

Example 2 with JndiBindingRegistry

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;
}
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 3 with JndiBindingRegistry

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();
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) InVMNamingContext(org.apache.activemq.artemis.tests.unit.util.InVMNamingContext) Before(org.junit.Before)

Example 4 with JndiBindingRegistry

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");
}
Also used : Role(org.apache.activemq.artemis.core.security.Role) AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) Configuration(org.apache.activemq.artemis.core.config.Configuration) ConnectionFactoryConfiguration(org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) HashSet(java.util.HashSet) InVMNamingContext(org.apache.activemq.artemis.tests.unit.util.InVMNamingContext) Before(org.junit.Before)

Example 5 with JndiBindingRegistry

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);
}
Also used : InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) NodeManager(org.apache.activemq.artemis.core.server.NodeManager) InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) InVMNodeManagerServer(org.apache.activemq.artemis.tests.util.InVMNodeManagerServer) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration)

Aggregations

JndiBindingRegistry (org.apache.activemq.artemis.core.registry.JndiBindingRegistry)26 JMSServerManagerImpl (org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl)25 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)20 InVMNamingContext (org.apache.activemq.artemis.tests.unit.util.InVMNamingContext)18 Configuration (org.apache.activemq.artemis.core.config.Configuration)13 Before (org.junit.Before)11 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)7 JMSConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl)6 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)4 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)4 ConnectionFactoryConfiguration (org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration)4 JMSConfiguration (org.apache.activemq.artemis.jms.server.config.JMSConfiguration)4 ActiveMQJAASSecurityManager (org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 SharedStoreMasterPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration)3 SharedStoreSlavePolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration)3 Role (org.apache.activemq.artemis.core.security.Role)3 JMSQueueConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl)3 ArrayList (java.util.ArrayList)2