Search in sources :

Example 1 with JMSServerManagerImpl

use of org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl in project activemq-artemis by apache.

the class ConnectionFactoryProvider method setupConnection.

@PostConstruct
public void setupConnection() {
    if (configuration.startEmbeddedBroker()) {
        try {
            ActiveMQServer activeMQServer = ActiveMQServers.newActiveMQServer(embeddedConfiguration, false);
            JMSServerManagerImpl jmsServerManager = new JMSServerManagerImpl(activeMQServer);
            jmsServerManager.start();
        } catch (Exception e) {
            throw new RuntimeException("Unable to start embedded JMS", e);
        }
    }
    try {
        this.activeMQConnectionFactory = createConnectionFactory();
    } catch (Exception e) {
        throw new RuntimeException("Unable to connect to remote server", e);
    }
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) PostConstruct(javax.annotation.PostConstruct)

Example 2 with JMSServerManagerImpl

use of org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl in project activemq-artemis by apache.

the class FileJMSConfiguration method buildService.

@Override
public void buildService(ActiveMQSecurityManager securityManager, MBeanServer mBeanServer, Map<String, Deployable> deployables, Map<String, ActiveMQComponent> components) throws Exception {
    ActiveMQServerImpl server = (ActiveMQServerImpl) components.get("core");
    components.put(CONFIGURATION_SCHEMA_ROOT_ELEMENT, new JMSServerManagerImpl(server, this));
}
Also used : JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl)

Example 3 with JMSServerManagerImpl

use of org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl 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 4 with JMSServerManagerImpl

use of org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl 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 5 with JMSServerManagerImpl

use of org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl 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)

Aggregations

JMSServerManagerImpl (org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl)34 JndiBindingRegistry (org.apache.activemq.artemis.core.registry.JndiBindingRegistry)25 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)22 InVMNamingContext (org.apache.activemq.artemis.tests.unit.util.InVMNamingContext)17 Configuration (org.apache.activemq.artemis.core.config.Configuration)15 Before (org.junit.Before)13 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)11 JMSConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl)7 ActiveMQJAASSecurityManager (org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager)7 HashMap (java.util.HashMap)5 ActiveMQServerImpl (org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl)5 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)5 JMSConfiguration (org.apache.activemq.artemis.jms.server.config.JMSConfiguration)5 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)4 ConnectionFactoryConfiguration (org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration)4 Test (org.junit.Test)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 FileDeploymentManager (org.apache.activemq.artemis.core.config.FileDeploymentManager)3 SharedStoreMasterPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration)3 SecurityConfiguration (org.apache.activemq.artemis.core.config.impl.SecurityConfiguration)3