Search in sources :

Example 26 with ActiveMQServer

use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.

the class HTTPUpgradeService method switchToMessagingProtocol.

private static HttpUpgradeListener switchToMessagingProtocol(final ActiveMQServer activemqServer, final String acceptorName, final String protocolName) {
    return new HttpUpgradeListener() {

        @Override
        public void handleUpgrade(StreamConnection streamConnection, HttpServerExchange exchange) {
            ChannelListener<StreamConnection> listener = new ChannelListener<StreamConnection>() {

                @Override
                public void handleEvent(StreamConnection connection) {
                    MessagingLogger.ROOT_LOGGER.debugf("Switching to %s protocol for %s http-acceptor", protocolName, acceptorName);
                    ActiveMQServer server = selectServer(exchange, activemqServer);
                    RemotingService remotingService = server.getRemotingService();
                    if (!server.isActive() || !remotingService.isStarted()) {
                        // ActiveMQ does not accept connection
                        IoUtils.safeClose(connection);
                        return;
                    }
                    NettyAcceptor acceptor = (NettyAcceptor) remotingService.getAcceptor(acceptorName);
                    SocketChannel channel = new WrappingXnioSocketChannel(connection);
                    try {
                        acceptor.transfer(channel);
                        connection.getSourceChannel().resumeReads();
                    } catch (IllegalStateException e) {
                        IoUtils.safeClose(connection);
                    }
                }
            };
            ChannelListeners.invokeChannelListener(streamConnection, listener);
        }
    };
}
Also used : HttpServerExchange(io.undertow.server.HttpServerExchange) WrappingXnioSocketChannel(org.xnio.netty.transport.WrappingXnioSocketChannel) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) SocketChannel(io.netty.channel.socket.SocketChannel) WrappingXnioSocketChannel(org.xnio.netty.transport.WrappingXnioSocketChannel) ChannelListener(org.xnio.ChannelListener) RemotingService(org.apache.activemq.artemis.core.remoting.server.RemotingService) NettyAcceptor(org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor) HttpUpgradeListener(io.undertow.server.HttpUpgradeListener) StreamConnection(org.xnio.StreamConnection)

Example 27 with ActiveMQServer

use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.

the class AddressControlHandler method getAddressControl.

private AddressControl getAddressControl(final OperationContext context, final ModelNode operation) {
    final String addressName = PathAddress.pathAddress(operation.require(OP_ADDR)).getLastElement().getValue();
    final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
    ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
    ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
    return AddressControl.class.cast(server.getManagementService().getResource(ResourceNames.CORE_ADDRESS + addressName));
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ServiceName(org.jboss.msc.service.ServiceName)

Example 28 with ActiveMQServer

use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.

the class AddressSettingAdd method performRuntime.

@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
    final ActiveMQServer server = getActiveMQServer(context, operation);
    if (server != null) {
        final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
        final AddressSettings settings = createSettings(context, model);
        server.getAddressSettingsRepository().addMatch(address.getLastElement().getValue(), settings);
    }
}
Also used : ActiveMQActivationService.getActiveMQServer(org.wildfly.extension.messaging.activemq.ActiveMQActivationService.getActiveMQServer) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) PathAddress(org.jboss.as.controller.PathAddress)

Example 29 with ActiveMQServer

use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.

the class AddressSettingsResolveHandler method executeRuntimeStep.

@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
    if (ignoreOperationIfServerNotActive(context, operation)) {
        return;
    }
    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    final ServiceName serviceName = MessagingServices.getActiveMQServiceName(address);
    ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
    ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
    final String activeMQAddress = ACTIVEMQ_ADDRESS.resolveModelAttribute(context, operation).asString();
    AddressSettings settings = server.getAddressSettingsRepository().getMatch(activeMQAddress);
    ModelNode result = context.getResult();
    result.get(ADDRESS_FULL_MESSAGE_POLICY.getName()).set(settings.getAddressFullMessagePolicy().toString());
    ModelNode deadLetterAddress = result.get(DEAD_LETTER_ADDRESS.getName());
    if (settings.getDeadLetterAddress() != null) {
        deadLetterAddress.set(settings.getDeadLetterAddress().toString());
    }
    ModelNode expiryAddress = result.get(EXPIRY_ADDRESS.getName());
    if (settings.getExpiryAddress() != null) {
        expiryAddress.set(settings.getExpiryAddress().toString());
    }
    result.get(EXPIRY_DELAY.getName()).set(settings.getExpiryDelay());
    result.get(LAST_VALUE_QUEUE.getName()).set(settings.isLastValueQueue());
    result.get(MAX_DELIVERY_ATTEMPTS.getName()).set(settings.getMaxDeliveryAttempts());
    result.get(MAX_REDELIVERY_DELAY.getName()).set(settings.getMaxRedeliveryDelay());
    result.get(MAX_SIZE_BYTES.getName()).set(settings.getMaxSizeBytes());
    result.get(MESSAGE_COUNTER_HISTORY_DAY_LIMIT.getName()).set(settings.getMessageCounterHistoryDayLimit());
    result.get(PAGE_MAX_CACHE_SIZE.getName()).set(settings.getPageCacheMaxSize());
    result.get(PAGE_SIZE_BYTES.getName()).set(settings.getPageSizeBytes());
    result.get(REDELIVERY_DELAY.getName()).set(settings.getRedeliveryDelay());
    result.get(REDELIVERY_MULTIPLIER.getName()).set(settings.getRedeliveryMultiplier());
    result.get(REDISTRIBUTION_DELAY.getName()).set(settings.getRedistributionDelay());
    result.get(SEND_TO_DLA_ON_NO_ROUTE.getName()).set(settings.isSendToDLAOnNoRoute());
    result.get(SLOW_CONSUMER_CHECK_PERIOD.getName()).set(settings.getSlowConsumerCheckPeriod());
    result.get(SLOW_CONSUMER_POLICY.getName()).set(settings.getSlowConsumerPolicy().toString());
    result.get(SLOW_CONSUMER_THRESHOLD.getName()).set(settings.getSlowConsumerThreshold());
    result.get(AUTO_CREATE_JMS_QUEUES.getName()).set(settings.isAutoCreateJmsQueues());
    result.get(AUTO_DELETE_JMS_QUEUES.getName()).set(settings.isAutoDeleteJmsQueues());
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 30 with ActiveMQServer

use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.

the class QueueReadAttributeHandler method executeRuntimeStep.

@Override
public void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
    if (ignoreOperationIfServerNotActive(context, operation)) {
        return;
    }
    validator.validate(operation);
    final String attributeName = operation.require(ModelDescriptionConstants.NAME).asString();
    PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
    String queueName = address.getLastElement().getValue();
    if (forwardToRuntimeQueue(context, operation, RUNTIME_INSTANCE)) {
        return;
    }
    final ServiceName serviceName = MessagingServices.getActiveMQServiceName(address);
    ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
    ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
    QueueControl control = QueueControl.class.cast(server.getManagementService().getResource(ResourceNames.CORE_QUEUE + queueName));
    if (control == null) {
        throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
    }
    if (MESSAGE_COUNT.getName().equals(attributeName)) {
        context.getResult().set(control.getMessageCount());
    } else if (SCHEDULED_COUNT.getName().equals(attributeName)) {
        context.getResult().set(control.getScheduledCount());
    } else if (CONSUMER_COUNT.getName().equals(attributeName)) {
        context.getResult().set(control.getConsumerCount());
    } else if (DELIVERING_COUNT.getName().equals(attributeName)) {
        context.getResult().set(control.getDeliveringCount());
    } else if (MESSAGES_ADDED.getName().equals(attributeName)) {
        context.getResult().set(control.getMessagesAdded());
    } else if (ID.getName().equals(attributeName)) {
        context.getResult().set(control.getID());
    } else if (PAUSED.getName().equals(attributeName)) {
        try {
            context.getResult().set(control.isPaused());
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    } else if (TEMPORARY.getName().equals(attributeName)) {
        context.getResult().set(control.isTemporary());
    } else if (EXPIRY_ADDRESS.getName().equals(attributeName)) {
        if (control.getExpiryAddress() != null) {
            context.getResult().set(control.getExpiryAddress());
        }
    } else if (DEAD_LETTER_ADDRESS.getName().equals(attributeName)) {
        if (control.getDeadLetterAddress() != null) {
            context.getResult().set(control.getDeadLetterAddress());
        }
    } else if (readStorageAttributes && getStorageAttributeNames().contains(attributeName)) {
        if (ADDRESS.getName().equals(attributeName)) {
            context.getResult().set(control.getAddress());
        } else if (DURABLE.getName().equals(attributeName)) {
            context.getResult().set(control.isDurable());
        } else if (FILTER.getName().equals(attributeName)) {
            ModelNode result = context.getResult();
            String filter = control.getFilter();
            if (filter != null) {
                result.set(filter);
            }
        }
    } else {
        throw MessagingLogger.ROOT_LOGGER.unsupportedAttribute(attributeName);
    }
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) QueueControl(org.apache.activemq.artemis.api.core.management.QueueControl) OperationFailedException(org.jboss.as.controller.OperationFailedException)

Aggregations

ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)37 ServiceName (org.jboss.msc.service.ServiceName)20 PathAddress (org.jboss.as.controller.PathAddress)19 OperationFailedException (org.jboss.as.controller.OperationFailedException)12 ModelNode (org.jboss.dmr.ModelNode)9 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)5 ActiveMQActivationService.getActiveMQServer (org.wildfly.extension.messaging.activemq.ActiveMQActivationService.getActiveMQServer)4 Role (org.apache.activemq.artemis.core.security.Role)3 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)3 HttpServerExchange (io.undertow.server.HttpServerExchange)2 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)2 ConnectionFactoryControl (org.apache.activemq.artemis.api.jms.management.ConnectionFactoryControl)2 JMSServerControl (org.apache.activemq.artemis.api.jms.management.JMSServerControl)2 TopicControl (org.apache.activemq.artemis.api.jms.management.TopicControl)2 RemotingService (org.apache.activemq.artemis.core.remoting.server.RemotingService)2 OperationContext (org.jboss.as.controller.OperationContext)2 Resource (org.jboss.as.controller.registry.Resource)2 ContextNames (org.jboss.as.naming.deployment.ContextNames)2 StartException (org.jboss.msc.service.StartException)2 SocketChannel (io.netty.channel.socket.SocketChannel)1