Search in sources :

Example 16 with JMSServerManagerImpl

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

the class BridgeTestBase method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    // Start the servers
    Configuration conf0 = createBasicConfig().setJournalDirectory(getJournalDir(0, false)).setBindingsDirectory(getBindingsDir(0, false)).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY));
    server0 = addServer(ActiveMQServers.newActiveMQServer(conf0, false));
    context0 = new InVMNamingContext();
    jmsServer0 = new JMSServerManagerImpl(server0);
    jmsServer0.setRegistry(new JndiBindingRegistry(context0));
    jmsServer0.start();
    params1 = new HashMap<>();
    params1.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
    Configuration conf1 = createBasicConfig().setJournalDirectory(getJournalDir(1, false)).setBindingsDirectory(getBindingsDir(1, false)).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params1));
    server1 = addServer(ActiveMQServers.newActiveMQServer(conf1, false));
    context1 = new InVMNamingContext();
    jmsServer1 = new JMSServerManagerImpl(server1);
    jmsServer1.setRegistry(new JndiBindingRegistry(context1));
    jmsServer1.start();
    createQueue("sourceQueue", 0);
    jmsServer0.createTopic(false, "sourceTopic", "/topic/sourceTopic");
    createQueue("localTargetQueue", 0);
    createQueue("targetQueue", 1);
    setUpAdministeredObjects();
    TxControl.enable();
// We need a local transaction and recovery manager
// We must start this after the remote servers have been created or it won't
// have deleted the database and the recovery manager may attempt to recover transactions
}
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) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) InVMNamingContext(org.apache.activemq.artemis.tests.unit.util.InVMNamingContext) Before(org.junit.Before)

Example 17 with JMSServerManagerImpl

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

the class JMSClusteredTestBase method setupServer2.

/**
 * @throws Exception
 */
private void setupServer2() throws Exception {
    Configuration configuration = createConfigServer(2, 1);
    JMSConfigurationImpl jmsconfig = new JMSConfigurationImpl();
    mBeanServer2 = MBeanServerFactory.createMBeanServer();
    server2 = addServer(ActiveMQServers.newActiveMQServer(configuration, mBeanServer2, enablePersistence()));
    jmsServer2 = new JMSServerManagerImpl(server2, jmsconfig);
    context2 = new InVMNamingContext();
    jmsServer2.setRegistry(new JndiBindingRegistry(context2));
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) InVMNamingContext(org.apache.activemq.artemis.tests.unit.util.InVMNamingContext)

Example 18 with JMSServerManagerImpl

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

the class SyncSendTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    if (storage.equals("null")) {
        server = createServer(false, true);
    } else {
        server = createServer(true, true);
    }
    jms = new JMSServerManagerImpl(server);
    if (storage.equals("libaio")) {
        server.getConfiguration().setJournalType(JournalType.ASYNCIO);
    } else {
        server.getConfiguration().setJournalType(JournalType.NIO);
    }
    jms.start();
}
Also used : JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl)

Example 19 with JMSServerManagerImpl

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

the class JMSService method doStart.

private synchronized void doStart(final StartContext context) throws StartException {
    final ServiceContainer serviceContainer = context.getController().getServiceContainer();
    ClassLoader oldTccl = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(getClass());
    try {
        jmsServer = new JMSServerManagerImpl(activeMQServer.getValue(), new WildFlyBindingRegistry(context.getController().getServiceContainer())) {

            @Override
            public void stop(ActiveMQServer server) {
            // Suppress ARTEMIS-2438
            }
        };
        activeMQServer.getValue().registerActivationFailureListener(e -> {
            StartException se = new StartException(e);
            context.failed(se);
        });
        activeMQServer.getValue().registerActivateCallback(new ActivateCallback() {

            private volatile ServiceController<Void> activeMQActivationController;

            public void preActivate() {
            }

            public void activated() {
                if (overrideInVMSecurity) {
                    activeMQServer.getValue().getRemotingService().allowInvmSecurityOverride(new ActiveMQPrincipal(DefaultCredentials.getUsername(), DefaultCredentials.getPassword()));
                }
                // ActiveMQ backup server is activated during failover while the WildFly server is shutting down.
                if (serviceContainer.isShutdown()) {
                    return;
                }
                if (activeMQActivationController == null) {
                    activeMQActivationController = serviceContainer.addService(ActiveMQActivationService.getServiceName(serverServiceName), new ActiveMQActivationService()).setInitialMode(Mode.ACTIVE).install();
                } else {
                    activeMQActivationController.setMode(ACTIVE);
                }
            }

            @Override
            public void activationComplete() {
            }

            public void deActivate() {
                // and *not* during AS7 service container shutdown or reload (AS7-6840 / AS7-6881)
                if (activeMQActivationController != null && !activeMQActivationController.getState().in(STOPPING, REMOVED)) {
                    // [WFLY-4597] When Artemis is deactivated during failover, we block until its
                    // activation controller is REMOVED before giving back control to Artemis.
                    // This allow to properly stop any service depending on the activation controller
                    // and avoid spurious warning messages because the resources used by the services
                    // are stopped outside the control of the services.
                    final CountDownLatch latch = new CountDownLatch(1);
                    activeMQActivationController.compareAndSetMode(ACTIVE, REMOVE);
                    activeMQActivationController.addListener(new LifecycleListener() {

                        @Override
                        public void handleEvent(ServiceController<?> controller, LifecycleEvent event) {
                            if (event == LifecycleEvent.REMOVED) {
                                latch.countDown();
                            }
                        }
                    });
                    try {
                        latch.await(5, TimeUnit.SECONDS);
                    } catch (InterruptedException e) {
                    }
                    activeMQActivationController = null;
                }
            }
        });
        jmsServer.start();
    } catch (StartException e) {
        throw e;
    } catch (Throwable t) {
        throw new StartException(t);
    } finally {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl);
    }
}
Also used : ActiveMQPrincipal(org.apache.activemq.artemis.core.security.ActiveMQPrincipal) LifecycleListener(org.jboss.msc.service.LifecycleListener) CountDownLatch(java.util.concurrent.CountDownLatch) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ServiceContainer(org.jboss.msc.service.ServiceContainer) ActiveMQActivationService(org.wildfly.extension.messaging.activemq.ActiveMQActivationService) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) LifecycleEvent(org.jboss.msc.service.LifecycleEvent) StartException(org.jboss.msc.service.StartException) ServiceController(org.jboss.msc.service.ServiceController) ActivateCallback(org.apache.activemq.artemis.core.server.ActivateCallback)

Example 20 with JMSServerManagerImpl

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

the class XmlImportExportTest method basicSetUp.

/**
 * @return ClientSession
 * @throws Exception
 */
private ClientSession basicSetUp() throws Exception {
    server = createServer(true);
    server.getConfiguration().getConnectorConfigurations().put("in-vm1", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
    server.getConfiguration().getConnectorConfigurations().put("in-vm2", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
    jmsServer = new JMSServerManagerImpl(server);
    addActiveMQComponent(jmsServer);
    namingContext = new InVMContext();
    jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
    jmsServer.start();
    locator = createInVMNonHALocator();
    factory = createSessionFactory(locator);
    checkForLongs();
    return addClientSession(factory.createSession(false, true, true));
}
Also used : JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) InVMContext(org.apache.activemq.artemis.tests.unit.util.InVMContext)

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