Search in sources :

Example 16 with ActiveMQServer

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

the class AddressSettingsWriteHandler method applyUpdateToRuntime.

@Override
protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode resolvedValue, final ModelNode currentValue, final HandbackHolder<RevertHandback> handbackHolder) throws OperationFailedException {
    final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
    final ActiveMQServer server = getActiveMQServer(context, operation);
    if (server != null) {
        final ModelNode model = resource.getModel();
        final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
        final AddressSettings settings = AddressSettingAdd.createSettings(context, model);
        final HierarchicalRepository<AddressSettings> repository = server.getAddressSettingsRepository();
        final String match = address.getLastElement().getValue();
        final AddressSettings existingSettings = repository.getMatch(match);
        repository.addMatch(match, settings);
        if (existingSettings != null) {
            handbackHolder.setHandback(new RevertHandback() {

                @Override
                public void doRevertUpdateToRuntime() {
                    // Restore the old settings
                    repository.addMatch(address.getLastElement().getValue(), existingSettings);
                }
            });
        }
    }
    return false;
}
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) Resource(org.jboss.as.controller.registry.Resource) ModelNode(org.jboss.dmr.ModelNode)

Example 17 with ActiveMQServer

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

the class DivertRemove method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final String name = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
    final ServiceRegistry registry = context.getServiceRegistry(true);
    final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
    final ServiceController<?> service = registry.getService(serviceName);
    if (service != null && service.getState() == ServiceController.State.UP) {
        ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
        try {
            server.getActiveMQServerControl().destroyDivert(name);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            // TODO should this be an OFE instead?
            throw new RuntimeException(e);
        }
    }
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ServiceName(org.jboss.msc.service.ServiceName) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) OperationFailedException(org.jboss.as.controller.OperationFailedException)

Example 18 with ActiveMQServer

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

the class LegacyConnectionFactoryService method start.

@Override
public void start(StartContext context) throws StartException {
    ActiveMQServer activeMQServer = injectedActiveMQServer.getValue();
    DiscoveryGroupConfiguration discoveryGroupConfiguration = null;
    if (discoveryGroupName != null) {
        if (activeMQServer.getConfiguration().getDiscoveryGroupConfigurations().keySet().contains(discoveryGroupName)) {
            discoveryGroupConfiguration = translateDiscoveryGroupConfiguration(activeMQServer.getConfiguration().getDiscoveryGroupConfigurations().get(discoveryGroupName));
        } else {
            throw MessagingLogger.ROOT_LOGGER.discoveryGroupIsNotDefined(discoveryGroupName);
        }
    }
    TransportConfiguration[] transportConfigurations = translateTransportGroupConfigurations(activeMQServer.getConfiguration().getConnectorConfigurations(), connectors);
    JMSFactoryType factoryType = JMSFactoryType.valueOf(uncompletedConnectionFactory.getFactoryType());
    if (uncompletedConnectionFactory.isHA()) {
        if (discoveryGroupConfiguration != null) {
            connectionFactory = HornetQJMSClient.createConnectionFactoryWithHA(discoveryGroupConfiguration, factoryType);
        } else {
            connectionFactory = HornetQJMSClient.createConnectionFactoryWithHA(factoryType, transportConfigurations);
        }
    } else {
        if (discoveryGroupConfiguration != null) {
            connectionFactory = HornetQJMSClient.createConnectionFactoryWithoutHA(discoveryGroupConfiguration, factoryType);
        } else {
            connectionFactory = HornetQJMSClient.createConnectionFactoryWithoutHA(factoryType, transportConfigurations);
        }
    }
    connectionFactory.setAutoGroup(uncompletedConnectionFactory.isAutoGroup());
    connectionFactory.setBlockOnAcknowledge(uncompletedConnectionFactory.isBlockOnAcknowledge());
    connectionFactory.setBlockOnDurableSend(uncompletedConnectionFactory.isBlockOnDurableSend());
    connectionFactory.setBlockOnNonDurableSend(uncompletedConnectionFactory.isBlockOnNonDurableSend());
    connectionFactory.setCacheLargeMessagesClient(uncompletedConnectionFactory.isCacheLargeMessagesClient());
    connectionFactory.setCallFailoverTimeout(uncompletedConnectionFactory.getCallFailoverTimeout());
    connectionFactory.setCallTimeout(uncompletedConnectionFactory.getCallTimeout());
    connectionFactory.setClientFailureCheckPeriod(uncompletedConnectionFactory.getClientFailureCheckPeriod());
    connectionFactory.setClientID(uncompletedConnectionFactory.getClientID());
    connectionFactory.setCompressLargeMessage(uncompletedConnectionFactory.isCompressLargeMessage());
    connectionFactory.setConfirmationWindowSize(uncompletedConnectionFactory.getConfirmationWindowSize());
    connectionFactory.setConnectionLoadBalancingPolicyClassName(uncompletedConnectionFactory.getConnectionLoadBalancingPolicyClassName());
    connectionFactory.setConnectionTTL(uncompletedConnectionFactory.getConnectionTTL());
    connectionFactory.setConsumerMaxRate(uncompletedConnectionFactory.getConsumerMaxRate());
    connectionFactory.setConsumerWindowSize(uncompletedConnectionFactory.getConsumerWindowSize());
    connectionFactory.setConfirmationWindowSize(uncompletedConnectionFactory.getConfirmationWindowSize());
    connectionFactory.setDupsOKBatchSize(uncompletedConnectionFactory.getDupsOKBatchSize());
    connectionFactory.setFailoverOnInitialConnection(uncompletedConnectionFactory.isFailoverOnInitialConnection());
    connectionFactory.setGroupID(uncompletedConnectionFactory.getGroupID());
    connectionFactory.setInitialConnectAttempts(uncompletedConnectionFactory.getInitialConnectAttempts());
    connectionFactory.setInitialMessagePacketSize(uncompletedConnectionFactory.getInitialMessagePacketSize());
    connectionFactory.setMaxRetryInterval(uncompletedConnectionFactory.getMaxRetryInterval());
    connectionFactory.setMinLargeMessageSize(uncompletedConnectionFactory.getMinLargeMessageSize());
    connectionFactory.setPreAcknowledge(uncompletedConnectionFactory.isPreAcknowledge());
    connectionFactory.setProducerMaxRate(uncompletedConnectionFactory.getProducerMaxRate());
    connectionFactory.setProducerWindowSize(uncompletedConnectionFactory.getProducerWindowSize());
    connectionFactory.setReconnectAttempts(uncompletedConnectionFactory.getReconnectAttempts());
    connectionFactory.setRetryInterval(uncompletedConnectionFactory.getRetryInterval());
    connectionFactory.setRetryIntervalMultiplier(uncompletedConnectionFactory.getRetryIntervalMultiplier());
    connectionFactory.setScheduledThreadPoolMaxSize(uncompletedConnectionFactory.getScheduledThreadPoolMaxSize());
    connectionFactory.setThreadPoolMaxSize(uncompletedConnectionFactory.getThreadPoolMaxSize());
    connectionFactory.setTransactionBatchSize(uncompletedConnectionFactory.getTransactionBatchSize());
    connectionFactory.setUseGlobalPools(uncompletedConnectionFactory.isUseGlobalPools());
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) JMSFactoryType(org.hornetq.api.jms.JMSFactoryType) TransportConfiguration(org.hornetq.api.core.TransportConfiguration) DiscoveryGroupConfiguration(org.hornetq.api.core.DiscoveryGroupConfiguration)

Example 19 with ActiveMQServer

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

the class AbstractActiveMQComponentControlHandler method getActiveMQComponentControl.

/**
     * Gets the runtime ActiveMQ control object that can help service this request.
     *
     * @param context  the operation context
     * @param operation the operation
     * @param forWrite {@code true} if this operation will modify the runtime; {@code false} if not.
     * @return the control object
     * @throws OperationFailedException
     */
protected final T getActiveMQComponentControl(final OperationContext context, final ModelNode operation, final boolean forWrite) throws OperationFailedException {
    final ServiceName artemisServiceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
    ServiceController<?> artemisService = context.getServiceRegistry(forWrite).getService(artemisServiceName);
    ActiveMQServer server = ActiveMQServer.class.cast(artemisService.getValue());
    PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
    T control = getActiveMQComponentControl(server, address);
    if (control == null) {
        throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
    }
    return control;
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) START(org.jboss.as.controller.descriptions.ModelDescriptionConstants.START) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress)

Example 20 with ActiveMQServer

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

the class ConnectionFactoryReadAttributeHandler 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();
    String factoryName = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.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());
    ConnectionFactoryControl control = ConnectionFactoryControl.class.cast(server.getManagementService().getResource(ResourceNames.JMS_CONNECTION_FACTORY + factoryName));
    if (control == null) {
        PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
        throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
    }
    if (HA.getName().equals(attributeName)) {
        context.getResult().set(control.isHA());
    } else if (ConnectionFactoryAttributes.Regular.FACTORY_TYPE.getName().equals(attributeName)) {
        context.getResult().set(control.getFactoryType());
    } else if (ConnectionFactoryAttributes.Regular.INITIAL_MESSAGE_PACKET_SIZE.getName().equals(attributeName)) {
        context.getResult().set(control.getInitialMessagePacketSize());
    } else {
        // Bug
        throw MessagingLogger.ROOT_LOGGER.unsupportedAttribute(attributeName);
    }
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ConnectionFactoryControl(org.apache.activemq.artemis.api.jms.management.ConnectionFactoryControl) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress)

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