Search in sources :

Example 1 with JMSServerManager

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

the class JMSTopicService method start.

@Override
public synchronized void start(final StartContext context) throws StartException {
    final JMSServerManager jmsManager = jmsServer.getValue();
    final Runnable task = new Runnable() {

        @Override
        public void run() {
            try {
                jmsManager.createTopic(false, name, jndi);
                topic = new ActiveMQTopic(name);
                context.complete();
            } catch (Throwable e) {
                context.failed(MessagingLogger.ROOT_LOGGER.failedToCreate(e, "queue"));
            }
        }
    };
    try {
        executorInjector.getValue().execute(task);
    } catch (RejectedExecutionException e) {
        task.run();
    } finally {
        context.asynchronous();
    }
}
Also used : JMSServerManager(org.apache.activemq.artemis.jms.server.JMSServerManager) ActiveMQTopic(org.apache.activemq.artemis.jms.client.ActiveMQTopic) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 2 with JMSServerManager

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

the class StompConnectionCleanupTest method createServer.

@Override
protected JMSServerManager createServer() throws Exception {
    JMSServerManager s = super.createServer();
    s.getActiveMQServer().getConfiguration().setConnectionTTLOverride(CONNECTION_TTL);
    return s;
}
Also used : JMSServerManager(org.apache.activemq.artemis.jms.server.JMSServerManager)

Example 3 with JMSServerManager

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

the class BridgeTestBase method createQueue.

protected void createQueue(final String queueName, final int index) throws Exception {
    JMSServerManager server = jmsServer0;
    if (index == 1) {
        server = jmsServer1;
    }
    assertTrue("queue '/queue/" + queueName + "' created", server.createQueue(false, queueName, null, true, "/queue/" + queueName));
}
Also used : JMSServerManager(org.apache.activemq.artemis.jms.server.JMSServerManager)

Example 4 with JMSServerManager

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

the class StompPluginTest method createServer.

@Override
protected JMSServerManager createServer() throws Exception {
    JMSServerManager server = super.createServer();
    server.getActiveMQServer().registerBrokerPlugin(verifier);
    server.getActiveMQServer().registerBrokerPlugin(new ActiveMQServerPlugin() {

        @Override
        public void beforeCreateSession(String name, String username, int minLargeMessageSize, RemotingConnection connection, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge, boolean xa, String defaultAddress, SessionCallback callback, boolean autoCreateQueues, OperationContext context, Map<SimpleString, RoutingType> prefixes) throws ActiveMQException {
            if (connection instanceof StompConnection) {
                stompBeforeCreateSession.set(true);
            }
        }

        @Override
        public void beforeCloseSession(ServerSession session, boolean failed) throws ActiveMQException {
            if (session.getRemotingConnection() instanceof StompConnection) {
                stompBeforeRemoveSession.set(true);
            }
        }
    });
    return server;
}
Also used : OperationContext(org.apache.activemq.artemis.core.persistence.OperationContext) JMSServerManager(org.apache.activemq.artemis.jms.server.JMSServerManager) ServerSession(org.apache.activemq.artemis.core.server.ServerSession) RemotingConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SessionCallback(org.apache.activemq.artemis.spi.core.protocol.SessionCallback) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQServerPlugin(org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin) StompConnection(org.apache.activemq.artemis.core.protocol.stomp.StompConnection) RoutingType(org.apache.activemq.artemis.api.core.RoutingType)

Example 5 with JMSServerManager

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

the class AbstractUpdateJndiHandler method execute.

@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    JNDI_BINDING.validateOperation(operation);
    final String jndiName = JNDI_BINDING.resolveModelAttribute(context, operation).asString();
    final ModelNode entries = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS).getModel().get(CommonAttributes.DESTINATION_ENTRIES.getName());
    if (addOperation) {
        for (ModelNode entry : entries.asList()) {
            if (jndiName.equals(entry.asString())) {
                throw new OperationFailedException(ROOT_LOGGER.jndiNameAlreadyRegistered(jndiName));
            }
        }
        entries.add(jndiName);
    } else {
        ModelNode updatedEntries = new ModelNode();
        boolean updated = false;
        for (ModelNode entry : entries.asList()) {
            if (jndiName.equals(entry.asString())) {
                if (entries.asList().size() == 1) {
                    throw new OperationFailedException(ROOT_LOGGER.canNotRemoveLastJNDIName(jndiName));
                }
                updated = true;
            } else {
                updatedEntries.add(entry);
            }
        }
        if (!updated) {
            throw MessagingLogger.ROOT_LOGGER.canNotRemoveUnknownEntry(jndiName);
        }
        context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS).getModel().get(CommonAttributes.DESTINATION_ENTRIES.getName()).set(updatedEntries);
    }
    if (context.isNormalServer()) {
        if (rollbackOperationIfServerNotActive(context, operation)) {
            return;
        }
        context.addStep(new OperationStepHandler() {

            @Override
            public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
                final String resourceName = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
                final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
                final ServiceName jmsManagerServiceName = JMSServices.getJmsManagerBaseServiceName(serviceName);
                final ServiceController<?> jmsServerService = context.getServiceRegistry(false).getService(jmsManagerServiceName);
                if (jmsServerService != null) {
                    JMSServerManager jmsServerManager = JMSServerManager.class.cast(jmsServerService.getValue());
                    if (jmsServerManager == null) {
                        PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
                        throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
                    }
                    try {
                        if (addOperation) {
                            addJndiName(jmsServerManager, resourceName, jndiName);
                        } else {
                            removeJndiName(jmsServerManager, resourceName, jndiName);
                        }
                    } catch (Exception e) {
                        context.getFailureDescription().set(e.getLocalizedMessage());
                    }
                }
                if (!context.hasFailureDescription()) {
                    context.getResult();
                }
                context.completeStep(new OperationContext.RollbackHandler() {

                    @Override
                    public void handleRollback(OperationContext context, ModelNode operation) {
                        if (jmsServerService != null) {
                            JMSServerManager jmsServerManager = JMSServerManager.class.cast(jmsServerService.getValue());
                            try {
                                if (addOperation) {
                                    removeJndiName(jmsServerManager, resourceName, jndiName);
                                } else {
                                    addJndiName(jmsServerManager, resourceName, jndiName);
                                }
                            } catch (Exception e) {
                                context.getFailureDescription().set(e.getLocalizedMessage());
                            }
                        }
                    }
                });
            }
        }, OperationContext.Stage.RUNTIME);
    }
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) JMSServerManager(org.apache.activemq.artemis.jms.server.JMSServerManager) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) OperationFailedException(org.jboss.as.controller.OperationFailedException) OperationFailedException(org.jboss.as.controller.OperationFailedException) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceController(org.jboss.msc.service.ServiceController) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

JMSServerManager (org.apache.activemq.artemis.jms.server.JMSServerManager)11 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)6 ArrayList (java.util.ArrayList)1 Connection (javax.jms.Connection)1 ConnectionFactory (javax.jms.ConnectionFactory)1 Queue (javax.jms.Queue)1 Topic (javax.jms.Topic)1 Context (javax.naming.Context)1 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)1 RoutingType (org.apache.activemq.artemis.api.core.RoutingType)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)1 OperationContext (org.apache.activemq.artemis.core.persistence.OperationContext)1 StompConnection (org.apache.activemq.artemis.core.protocol.stomp.StompConnection)1 JndiBindingRegistry (org.apache.activemq.artemis.core.registry.JndiBindingRegistry)1 InVMConnectorFactory (org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory)1 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)1 ServerSession (org.apache.activemq.artemis.core.server.ServerSession)1 ActiveMQServerImpl (org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl)1 ActiveMQServerPlugin (org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin)1