Search in sources :

Example 1 with BridgeConfiguration

use of org.apache.activemq.artemis.core.config.BridgeConfiguration in project wildfly by wildfly.

the class BridgeAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    ServiceRegistry registry = context.getServiceRegistry(true);
    final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
    ServiceController<?> service = registry.getService(serviceName);
    if (service != null) {
        // The original subsystem initialization is complete; use the control object to create the divert
        if (service.getState() != ServiceController.State.UP) {
            throw MessagingLogger.ROOT_LOGGER.invalidServiceState(serviceName, ServiceController.State.UP, service.getState());
        }
        final String name = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
        BridgeConfiguration bridgeConfig = createBridgeConfiguration(context, name, model);
        ActiveMQServerControl serverControl = ActiveMQServer.class.cast(service.getValue()).getActiveMQServerControl();
        createBridge(name, bridgeConfig, serverControl);
    }
// else the initial subsystem install is not complete; MessagingSubsystemAdd will add a
// handler that calls addBridgeConfigs
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ActiveMQServerControl(org.apache.activemq.artemis.api.core.management.ActiveMQServerControl) ServiceName(org.jboss.msc.service.ServiceName) BridgeConfiguration(org.apache.activemq.artemis.core.config.BridgeConfiguration) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 2 with BridgeConfiguration

use of org.apache.activemq.artemis.core.config.BridgeConfiguration in project wildfly by wildfly.

the class BridgeRemove method recoverServices.

@Override
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    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) {
        final String name = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
        final BridgeConfiguration bridgeConfiguration = BridgeAdd.createBridgeConfiguration(context, name, model);
        ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
        BridgeAdd.createBridge(name, bridgeConfiguration, server.getActiveMQServerControl());
    }
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ServiceName(org.jboss.msc.service.ServiceName) BridgeConfiguration(org.apache.activemq.artemis.core.config.BridgeConfiguration) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 3 with BridgeConfiguration

use of org.apache.activemq.artemis.core.config.BridgeConfiguration in project wildfly by wildfly.

the class ServerAdd method addBridgeCredentialStoreReference.

private static void addBridgeCredentialStoreReference(ActiveMQServerService amqService, Configuration configuration, ObjectTypeAttributeDefinition credentialReferenceAttributeDefinition, OperationContext context, ModelNode model, ServiceBuilder<?> serviceBuilder) throws OperationFailedException {
    for (BridgeConfiguration bridgeConfiguration : configuration.getBridgeConfigurations()) {
        String name = bridgeConfiguration.getName();
        InjectedValue<ExceptionSupplier<CredentialSource, Exception>> injector = amqService.getBridgeCredentialSourceSupplierInjector(name);
        String[] modelFilter = { CommonAttributes.BRIDGE, name };
        ModelNode filteredModelNode = model;
        if (modelFilter != null && modelFilter.length > 0) {
            for (String path : modelFilter) {
                if (filteredModelNode.get(path).isDefined())
                    filteredModelNode = filteredModelNode.get(path);
                else
                    break;
            }
        }
        ModelNode value = credentialReferenceAttributeDefinition.resolveModelAttribute(context, filteredModelNode);
        if (value.isDefined()) {
            injector.inject(CredentialReference.getCredentialSourceSupplier(context, credentialReferenceAttributeDefinition, filteredModelNode, serviceBuilder));
        }
    }
}
Also used : ExceptionSupplier(org.wildfly.common.function.ExceptionSupplier) BridgeConfiguration(org.apache.activemq.artemis.core.config.BridgeConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ModelNode(org.jboss.dmr.ModelNode)

Example 4 with BridgeConfiguration

use of org.apache.activemq.artemis.core.config.BridgeConfiguration in project wildfly by wildfly.

the class BridgeAdd method createBridgeConfiguration.

static BridgeConfiguration createBridgeConfiguration(final OperationContext context, final String name, final ModelNode model) throws OperationFailedException {
    final String queueName = QUEUE_NAME.resolveModelAttribute(context, model).asString();
    final ModelNode forwardingNode = FORWARDING_ADDRESS.resolveModelAttribute(context, model);
    final String forwardingAddress = forwardingNode.isDefined() ? forwardingNode.asString() : null;
    final ModelNode filterNode = CommonAttributes.FILTER.resolveModelAttribute(context, model);
    final String filterString = filterNode.isDefined() ? filterNode.asString() : null;
    final ModelNode transformerNode = CommonAttributes.TRANSFORMER_CLASS_NAME.resolveModelAttribute(context, model);
    final String transformerClassName = transformerNode.isDefined() ? transformerNode.asString() : null;
    final int minLargeMessageSize = CommonAttributes.MIN_LARGE_MESSAGE_SIZE.resolveModelAttribute(context, model).asInt();
    final long retryInterval = CommonAttributes.RETRY_INTERVAL.resolveModelAttribute(context, model).asLong();
    final double retryIntervalMultiplier = CommonAttributes.RETRY_INTERVAL_MULTIPLIER.resolveModelAttribute(context, model).asDouble();
    final long maxRetryInterval = CommonAttributes.MAX_RETRY_INTERVAL.resolveModelAttribute(context, model).asLong();
    final int initialConnectAttempts = INITIAL_CONNECT_ATTEMPTS.resolveModelAttribute(context, model).asInt();
    final int reconnectAttempts = RECONNECT_ATTEMPTS.resolveModelAttribute(context, model).asInt();
    final int reconnectAttemptsOnSameNode = RECONNECT_ATTEMPTS_ON_SAME_NODE.resolveModelAttribute(context, model).asInt();
    final boolean useDuplicateDetection = USE_DUPLICATE_DETECTION.resolveModelAttribute(context, model).asBoolean();
    final int confirmationWindowSize = CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE.resolveModelAttribute(context, model).asInt();
    final int producerWindowSize = PRODUCER_WINDOW_SIZE.resolveModelAttribute(context, model).asInt();
    final long clientFailureCheckPeriod = CommonAttributes.CHECK_PERIOD.resolveModelAttribute(context, model).asLong();
    final long connectionTTL = CommonAttributes.CONNECTION_TTL.resolveModelAttribute(context, model).asLong();
    final ModelNode discoveryNode = DISCOVERY_GROUP_NAME.resolveModelAttribute(context, model);
    final String discoveryGroupName = discoveryNode.isDefined() ? discoveryNode.asString() : null;
    List<String> staticConnectors = discoveryGroupName == null ? getStaticConnectors(model) : null;
    final boolean ha = CommonAttributes.HA.resolveModelAttribute(context, model).asBoolean();
    final String user = USER.resolveModelAttribute(context, model).asString();
    final String password = PASSWORD.resolveModelAttribute(context, model).asString();
    BridgeConfiguration config = new BridgeConfiguration().setName(name).setQueueName(queueName).setForwardingAddress(forwardingAddress).setFilterString(filterString).setTransformerClassName(transformerClassName).setMinLargeMessageSize(minLargeMessageSize).setClientFailureCheckPeriod(clientFailureCheckPeriod).setConnectionTTL(connectionTTL).setRetryInterval(retryInterval).setMaxRetryInterval(maxRetryInterval).setRetryIntervalMultiplier(retryIntervalMultiplier).setInitialConnectAttempts(initialConnectAttempts).setReconnectAttempts(reconnectAttempts).setReconnectAttemptsOnSameNode(reconnectAttemptsOnSameNode).setUseDuplicateDetection(useDuplicateDetection).setConfirmationWindowSize(confirmationWindowSize).setProducerWindowSize(producerWindowSize).setHA(ha).setUser(user).setPassword(password);
    if (discoveryGroupName != null) {
        config.setDiscoveryGroupName(discoveryGroupName);
    } else {
        config.setStaticConnectors(staticConnectors);
    }
    return config;
}
Also used : BridgeConfiguration(org.apache.activemq.artemis.core.config.BridgeConfiguration) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

BridgeConfiguration (org.apache.activemq.artemis.core.config.BridgeConfiguration)4 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)2 ModelNode (org.jboss.dmr.ModelNode)2 ServiceName (org.jboss.msc.service.ServiceName)2 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)2 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 ActiveMQServerControl (org.apache.activemq.artemis.api.core.management.ActiveMQServerControl)1 ExceptionSupplier (org.wildfly.common.function.ExceptionSupplier)1