Search in sources :

Example 21 with DiscoveryGroupConfiguration

use of org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration in project activemq-artemis by apache.

the class ConnectionFactorySerializationTest method createDiscoveryFactoryJGroupsFile.

private void createDiscoveryFactoryJGroupsFile() throws Exception {
    // Deploy a connection factory with discovery
    List<String> bindings = new ArrayList<>();
    bindings.add("MyConnectionFactory");
    JGroupsFileBroadcastEndpointFactory config = new JGroupsFileBroadcastEndpointFactory().setChannelName("myChannel").setFile("/META-INF/myfile.xml");
    DiscoveryGroupConfiguration dcConfig = new DiscoveryGroupConfiguration().setName("dg1").setRefreshTimeout(5000).setDiscoveryInitialWaitTimeout(5000).setBroadcastEndpointFactory(config);
    jmsServer.getActiveMQServer().getConfiguration().getDiscoveryGroupConfigurations().put(dcConfig.getName(), dcConfig);
    jmsServer.createConnectionFactory("MyConnectionFactory", false, JMSFactoryType.CF, dcConfig.getName(), "/MyConnectionFactory");
}
Also used : ArrayList(java.util.ArrayList) JGroupsFileBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)

Example 22 with DiscoveryGroupConfiguration

use of org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration in project activemq-artemis by apache.

the class ClusterTestBase method setupBackupServerWithDiscovery.

protected void setupBackupServerWithDiscovery(final int node, final int liveNode, final String groupAddress, final int port, final boolean fileStorage, final boolean netty, final boolean sharedStorage) throws Exception {
    if (servers[node] != null) {
        throw new IllegalArgumentException("Already a server at node " + node);
    }
    Map<String, Object> params = generateParams(node, netty);
    TransportConfiguration connector = createTransportConfiguration(netty, false, params);
    List<String> connectorPairs = new ArrayList<>();
    connectorPairs.add(connector.getName());
    UDPBroadcastEndpointFactory endpoint = new UDPBroadcastEndpointFactory().setGroupAddress(groupAddress).setGroupPort(port);
    BroadcastGroupConfiguration bcConfig = new BroadcastGroupConfiguration().setName("bg1").setBroadcastPeriod(1000).setConnectorInfos(connectorPairs).setEndpointFactory(endpoint);
    DiscoveryGroupConfiguration dcConfig = new DiscoveryGroupConfiguration().setName("dg1").setRefreshTimeout(5000).setDiscoveryInitialWaitTimeout(5000).setBroadcastEndpointFactory(endpoint);
    Configuration configuration = createBasicConfig(sharedStorage ? liveNode : node).clearAcceptorConfigurations().addAcceptorConfiguration(createTransportConfiguration(netty, true, params)).addConnectorConfiguration(connector.getName(), connector).addBroadcastGroupConfiguration(bcConfig).addDiscoveryGroupConfiguration(dcConfig.getName(), dcConfig).setHAPolicyConfiguration(sharedStorage ? new SharedStoreSlavePolicyConfiguration() : new ReplicatedPolicyConfiguration());
    ActiveMQServer server;
    if (sharedStorage) {
        server = createInVMFailoverServer(fileStorage, configuration, nodeManagers[liveNode], liveNode);
    } else {
        boolean enablePersistency = fileStorage ? configuration.isPersistenceEnabled() : false;
        server = addServer(ActiveMQServers.newActiveMQServer(configuration, enablePersistency));
    }
    servers[node] = server;
}
Also used : GroupingHandlerConfiguration(org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) ActiveMQDefaultConfiguration(org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration) ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) LiveOnlyPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration) ArrayList(java.util.ArrayList) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration)

Example 23 with DiscoveryGroupConfiguration

use of org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration in project activemq-artemis by apache.

the class BridgeWithDiscoveryGroupStartTest method testStartStop.

@Test
public void testStartStop() throws Exception {
    Map<String, Object> server0Params = new HashMap<>();
    ActiveMQServer server0 = createClusteredServerWithParams(isNetty(), 0, true, server0Params);
    Map<String, Object> server1Params = new HashMap<>();
    if (isNetty()) {
        server1Params.put("port", TransportConstants.DEFAULT_PORT + 1);
    } else {
        server1Params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, 1);
    }
    ActiveMQServer server1 = createClusteredServerWithParams(isNetty(), 1, true, server1Params);
    ServerLocator locator = null;
    try {
        Map<String, TransportConfiguration> connectors = new HashMap<>();
        TransportConfiguration server0tc = new TransportConfiguration(getConnector(), server0Params);
        TransportConfiguration server1tc = new TransportConfiguration(getConnector(), server1Params);
        connectors.put(server1tc.getName(), server1tc);
        server0.getConfiguration().setConnectorConfigurations(connectors);
        final String testAddress = "testAddress";
        final String queueName0 = "queue0";
        final String forwardAddress = "forwardAddress";
        final String queueName1 = "queue1";
        final String groupAddress = getUDPDiscoveryAddress();
        final int port = getUDPDiscoveryPort();
        ArrayList<String> list = new ArrayList<>();
        list.add(server1tc.getName());
        UDPBroadcastEndpointFactory endpoint = new UDPBroadcastEndpointFactory().setGroupAddress(groupAddress).setGroupPort(port);
        BroadcastGroupConfiguration bcConfig = new BroadcastGroupConfiguration().setName("bg1").setBroadcastPeriod(250).setConnectorInfos(list).setEndpointFactory(endpoint);
        server0.getConfiguration().getBroadcastGroupConfigurations().add(bcConfig);
        DiscoveryGroupConfiguration dcConfig = new DiscoveryGroupConfiguration().setName("dg1").setRefreshTimeout(5000).setDiscoveryInitialWaitTimeout(5000).setBroadcastEndpointFactory(endpoint);
        server0.getConfiguration().getDiscoveryGroupConfigurations().put(dcConfig.getName(), dcConfig);
        final String bridgeName = "bridge1";
        ArrayList<String> staticConnectors = new ArrayList<>();
        staticConnectors.add(server1tc.getName());
        BridgeConfiguration bridgeConfiguration = new BridgeConfiguration().setName(bridgeName).setQueueName(queueName0).setForwardingAddress(forwardAddress).setRetryInterval(1000).setReconnectAttempts(0).setReconnectAttemptsOnSameNode(0).setConfirmationWindowSize(1024).setStaticConnectors(staticConnectors);
        List<BridgeConfiguration> bridgeConfigs = new ArrayList<>();
        bridgeConfigs.add(bridgeConfiguration);
        server0.getConfiguration().setBridgeConfigurations(bridgeConfigs);
        CoreQueueConfiguration queueConfig0 = new CoreQueueConfiguration().setAddress(testAddress).setName(queueName0);
        List<CoreQueueConfiguration> queueConfigs0 = new ArrayList<>();
        queueConfigs0.add(queueConfig0);
        server0.getConfiguration().setQueueConfigurations(queueConfigs0);
        CoreQueueConfiguration queueConfig1 = new CoreQueueConfiguration().setAddress(forwardAddress).setName(queueName1);
        List<CoreQueueConfiguration> queueConfigs1 = new ArrayList<>();
        queueConfigs1.add(queueConfig1);
        server1.getConfiguration().setQueueConfigurations(queueConfigs1);
        server1.start();
        server0.start();
        locator = ActiveMQClient.createServerLocatorWithoutHA(server0tc, server1tc);
        ClientSessionFactory sf0 = locator.createSessionFactory(server0tc);
        ClientSessionFactory sf1 = locator.createSessionFactory(server1tc);
        ClientSession session0 = sf0.createSession(false, true, true);
        ClientSession session1 = sf1.createSession(false, true, true);
        ClientProducer producer0 = session0.createProducer(new SimpleString(testAddress));
        ClientConsumer consumer1 = session1.createConsumer(queueName1);
        session1.start();
        final int numMessages = 10;
        final SimpleString propKey = new SimpleString("testkey");
        for (int i = 0; i < numMessages; i++) {
            ClientMessage message = session0.createMessage(false);
            message.putIntProperty(propKey, i);
            producer0.send(message);
        }
        for (int i = 0; i < numMessages; i++) {
            ClientMessage message = consumer1.receive(BridgeWithDiscoveryGroupStartTest.TIMEOUT);
            Assert.assertNotNull(message);
            Assert.assertEquals(i, message.getObjectProperty(propKey));
            message.acknowledge();
        }
        Assert.assertNull(consumer1.receiveImmediate());
        Bridge bridge = server0.getClusterManager().getBridges().get(bridgeName);
        bridge.stop();
        bridge.flushExecutor();
        for (int i = 0; i < numMessages; i++) {
            ClientMessage message = session0.createMessage(false);
            message.putIntProperty(propKey, i);
            producer0.send(message);
        }
        Assert.assertNull(consumer1.receiveImmediate());
        bridge.start();
        for (int i = 0; i < numMessages; i++) {
            ClientMessage message = consumer1.receive(BridgeWithDiscoveryGroupStartTest.TIMEOUT);
            Assert.assertNotNull(message);
            Assert.assertEquals(i, message.getObjectProperty(propKey));
            message.acknowledge();
        }
        Assert.assertNull(consumer1.receiveImmediate());
        session0.close();
        session1.close();
        sf0.close();
        sf1.close();
    } finally {
        if (locator != null) {
            locator.close();
        }
        server0.stop();
        server1.stop();
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) CoreQueueConfiguration(org.apache.activemq.artemis.core.config.CoreQueueConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration) ClientProducer(org.apache.activemq.artemis.api.core.client.ClientProducer) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) BridgeConfiguration(org.apache.activemq.artemis.core.config.BridgeConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ClientConsumer(org.apache.activemq.artemis.api.core.client.ClientConsumer) Bridge(org.apache.activemq.artemis.core.server.cluster.Bridge) Test(org.junit.Test)

Example 24 with DiscoveryGroupConfiguration

use of org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration in project activemq-artemis by apache.

the class ResourceAdapterTest method testResourceAdapterSetupNoOverrideDiscovery.

@Test
public void testResourceAdapterSetupNoOverrideDiscovery() throws Exception {
    ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter();
    qResourceAdapter.setDiscoveryAddress("231.6.6.6");
    qResourceAdapter.setDiscoveryPort(1234);
    qResourceAdapter.setDiscoveryRefreshTimeout(1L);
    qResourceAdapter.setDiscoveryInitialWaitTimeout(1L);
    ActiveMQRATestBase.MyBootstrapContext ctx = new ActiveMQRATestBase.MyBootstrapContext();
    qResourceAdapter.start(ctx);
    ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
    spec.setResourceAdapter(qResourceAdapter);
    spec.setUseJNDI(false);
    spec.setDestinationType("javax.jms.Queue");
    spec.setDestination(MDBQUEUE);
    ActiveMQConnectionFactory fac = qResourceAdapter.getConnectionFactory(spec);
    DiscoveryGroupConfiguration dc = fac.getServerLocator().getDiscoveryGroupConfiguration();
    UDPBroadcastEndpointFactory udpDg = (UDPBroadcastEndpointFactory) dc.getBroadcastEndpointFactory();
    assertEquals(udpDg.getGroupAddress(), "231.6.6.6");
    assertEquals(udpDg.getGroupPort(), 1234);
    assertEquals(dc.getRefreshTimeout(), 1L);
    assertEquals(dc.getDiscoveryInitialWaitTimeout(), 1L);
    qResourceAdapter.stop();
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) ActiveMQActivationSpec(org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) Test(org.junit.Test)

Example 25 with DiscoveryGroupConfiguration

use of org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration in project wildfly by wildfly.

the class MessagingSubsystemAdd method performBoottime.

@Override
protected void performBoottime(final OperationContext context, ModelNode operation, final ModelNode model) throws OperationFailedException {
    // Cache support for capability service name lookups by our services
    MessagingServices.capabilityServiceSupport = context.getCapabilityServiceSupport();
    context.addStep(new AbstractDeploymentChainStep() {

        @Override
        protected void execute(DeploymentProcessorTarget processorTarget) {
            // keep the statements ordered by phase + priority
            processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_JMS_CONNECTION_FACTORY_RESOURCE_INJECTION, new DefaultJMSConnectionFactoryResourceReferenceProcessor());
            processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_RESOURCE_DEF_ANNOTATION_JMS_DESTINATION, new JMSDestinationDefinitionAnnotationProcessor());
            processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_RESOURCE_DEF_ANNOTATION_JMS_CONNECTION_FACTORY, new JMSConnectionFactoryDefinitionAnnotationProcessor(MessagingServices.capabilityServiceSupport.hasCapability("org.wildfly.legacy-security")));
            processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_MESSAGING_XML_RESOURCES, new MessagingXmlParsingDeploymentUnitProcessor());
            processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_JMS, new MessagingDependencyProcessor());
            if (MessagingServices.capabilityServiceSupport.hasCapability(WELD_CAPABILITY_NAME)) {
                processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_JMS_CDI_EXTENSIONS, new CDIDeploymentProcessor());
            }
            processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_RESOURCE_DEF_XML_JMS_CONNECTION_FACTORY, new JMSConnectionFactoryDefinitionDescriptorProcessor());
            processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_RESOURCE_DEF_XML_JMS_DESTINATION, new JMSDestinationDefinitionDescriptorProcessor());
            processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_DEFAULT_BINDINGS_JMS_CONNECTION_FACTORY, new DefaultJMSConnectionFactoryBindingProcessor());
            processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_MESSAGING_XML_RESOURCES, new MessagingXmlInstallDeploymentUnitProcessor());
        }
    }, OperationContext.Stage.RUNTIME);
    ModelNode threadPoolMaxSize = operation.get(GLOBAL_CLIENT_THREAD_POOL_MAX_SIZE.getName());
    ModelNode scheduledThreadPoolMaxSize = operation.get(GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_MAX_SIZE.getName());
    Integer threadPoolMaxSizeValue;
    Integer scheduledThreadPoolMaxSizeValue;
    // if the attributes are defined, their value is used (and the system properties are ignored)
    Properties sysprops = System.getProperties();
    if (threadPoolMaxSize.isDefined()) {
        threadPoolMaxSizeValue = GLOBAL_CLIENT_THREAD_POOL_MAX_SIZE.resolveModelAttribute(context, operation).asInt();
    } else if (sysprops.containsKey(THREAD_POOL_MAX_SIZE_PROPERTY_KEY)) {
        threadPoolMaxSizeValue = Integer.parseInt(sysprops.getProperty(THREAD_POOL_MAX_SIZE_PROPERTY_KEY));
    } else {
        // property is not configured using sysprop or explicit attribute
        threadPoolMaxSizeValue = null;
    }
    if (scheduledThreadPoolMaxSize.isDefined()) {
        scheduledThreadPoolMaxSizeValue = GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_MAX_SIZE.resolveModelAttribute(context, operation).asInt();
    } else if (sysprops.containsKey(SCHEDULED_THREAD_POOL_SIZE_PROPERTY_KEY)) {
        scheduledThreadPoolMaxSizeValue = Integer.parseInt(sysprops.getProperty(SCHEDULED_THREAD_POOL_SIZE_PROPERTY_KEY));
    } else {
        // property is not configured using sysprop or explicit attribute
        scheduledThreadPoolMaxSizeValue = null;
    }
    if (threadPoolMaxSizeValue != null || scheduledThreadPoolMaxSizeValue != null) {
        ActiveMQClient.initializeGlobalThreadPoolProperties();
        if (threadPoolMaxSizeValue == null) {
            threadPoolMaxSizeValue = ActiveMQClient.getGlobalThreadPoolSize();
        }
        if (scheduledThreadPoolMaxSizeValue == null) {
            scheduledThreadPoolMaxSizeValue = ActiveMQClient.getGlobalScheduledThreadPoolSize();
        }
        MessagingLogger.ROOT_LOGGER.debugf("Setting global client thread pool size to: regular=%s, scheduled=%s", threadPoolMaxSizeValue, scheduledThreadPoolMaxSizeValue);
        ActiveMQClient.setGlobalThreadPoolProperties(threadPoolMaxSizeValue, scheduledThreadPoolMaxSizeValue);
    }
    context.getServiceTarget().addService(MessagingServices.ACTIVEMQ_CLIENT_THREAD_POOL).setInstance(new ThreadPoolService()).install();
    context.addStep(new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            final ServiceTarget serviceTarget = context.getServiceTarget();
            final ServiceBuilder serviceBuilder = serviceTarget.addService(CONFIGURATION_CAPABILITY.getCapabilityServiceName());
            // Transform the configuration based on the recursive model
            final ModelNode model = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
            // Process connectors
            final Set<String> connectorsSocketBindings = new HashSet<String>();
            final Map<String, TransportConfiguration> connectors = TransportConfigOperationHandlers.processConnectors(context, "localhost", model, connectorsSocketBindings);
            Map<String, ServiceName> outboundSocketBindings = new HashMap<>();
            Map<String, Boolean> outbounds = TransportConfigOperationHandlers.listOutBoundSocketBinding(context, connectorsSocketBindings);
            Map<String, ServiceName> socketBindings = new HashMap<>();
            for (final String connectorSocketBinding : connectorsSocketBindings) {
                // find whether the connectorSocketBinding references a SocketBinding or an OutboundSocketBinding
                if (outbounds.get(connectorSocketBinding)) {
                    final ServiceName outboundSocketName = OUTBOUND_SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(connectorSocketBinding);
                    outboundSocketBindings.put(connectorSocketBinding, outboundSocketName);
                } else {
                    // check if the socket binding has not already been added by the acceptors
                    if (!socketBindings.containsKey(connectorSocketBinding)) {
                        socketBindings.put(connectorSocketBinding, SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(connectorSocketBinding));
                    }
                }
            }
            final List<BroadcastGroupConfiguration> broadcastGroupConfigurations = new ArrayList<>();
            // this requires connectors
            BroadcastGroupAdd.addBroadcastGroupConfigs(context, broadcastGroupConfigurations, connectors.keySet(), model);
            final Map<String, DiscoveryGroupConfiguration> discoveryGroupConfigurations = ConfigurationHelper.addDiscoveryGroupConfigurations(context, model);
            final Map<String, String> clusterNames = new HashMap<>();
            final Map<String, ServiceName> commandDispatcherFactories = new HashMap<>();
            final Map<String, ServiceName> groupBindings = new HashMap<>();
            final Set<ServiceName> groupBindingServices = new HashSet<>();
            for (final BroadcastGroupConfiguration config : broadcastGroupConfigurations) {
                final String name = config.getName();
                final String key = "broadcast" + name;
                if (model.hasDefined(JGROUPS_BROADCAST_GROUP, name)) {
                    ModelNode broadcastGroupModel = model.get(JGROUPS_BROADCAST_GROUP, name);
                    String channelName = JGroupsBroadcastGroupDefinition.JGROUPS_CHANNEL.resolveModelAttribute(context, broadcastGroupModel).asStringOrNull();
                    MessagingSubsystemAdd.this.broadcastCommandDispatcherFactoryInstaller.accept(context, channelName);
                    commandDispatcherFactories.put(key, MessagingServices.getBroadcastCommandDispatcherFactoryServiceName(channelName));
                    String clusterName = JGROUPS_CLUSTER.resolveModelAttribute(context, broadcastGroupModel).asString();
                    clusterNames.put(key, clusterName);
                } else {
                    final ServiceName groupBindingServiceName = GroupBindingService.getBroadcastBaseServiceName(JBOSS_MESSAGING_ACTIVEMQ).append(name);
                    if (!groupBindingServices.contains(groupBindingServiceName)) {
                        groupBindingServices.add(groupBindingServiceName);
                    }
                    groupBindings.put(key, groupBindingServiceName);
                }
            }
            for (final DiscoveryGroupConfiguration config : discoveryGroupConfigurations.values()) {
                final String name = config.getName();
                final String key = "discovery" + name;
                if (model.hasDefined(JGROUPS_DISCOVERY_GROUP, name)) {
                    ModelNode discoveryGroupModel = model.get(JGROUPS_DISCOVERY_GROUP, name);
                    String channelName = JGroupsDiscoveryGroupDefinition.JGROUPS_CHANNEL.resolveModelAttribute(context, discoveryGroupModel).asStringOrNull();
                    MessagingSubsystemAdd.this.broadcastCommandDispatcherFactoryInstaller.accept(context, channelName);
                    commandDispatcherFactories.put(key, MessagingServices.getBroadcastCommandDispatcherFactoryServiceName(channelName));
                    String clusterName = JGROUPS_CLUSTER.resolveModelAttribute(context, discoveryGroupModel).asString();
                    clusterNames.put(key, clusterName);
                } else {
                    final ServiceName groupBindingServiceName = GroupBindingService.getDiscoveryBaseServiceName(JBOSS_MESSAGING_ACTIVEMQ).append(name);
                    if (!groupBindingServices.contains(groupBindingServiceName)) {
                        groupBindingServices.add(groupBindingServiceName);
                    }
                    groupBindings.put(key, groupBindingServiceName);
                }
            }
            serviceBuilder.setInstance(new ExternalBrokerConfigurationService(connectors, discoveryGroupConfigurations, socketBindings, outboundSocketBindings, groupBindings, commandDispatcherFactories, clusterNames)).install();
        }
    }, OperationContext.Stage.RUNTIME);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Properties(java.util.Properties) JMSConnectionFactoryDefinitionDescriptorProcessor(org.wildfly.extension.messaging.activemq.deployment.JMSConnectionFactoryDefinitionDescriptorProcessor) DefaultJMSConnectionFactoryResourceReferenceProcessor(org.wildfly.extension.messaging.activemq.deployment.DefaultJMSConnectionFactoryResourceReferenceProcessor) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) JMSConnectionFactoryDefinitionAnnotationProcessor(org.wildfly.extension.messaging.activemq.deployment.JMSConnectionFactoryDefinitionAnnotationProcessor) List(java.util.List) ArrayList(java.util.ArrayList) DefaultJMSConnectionFactoryBindingProcessor(org.wildfly.extension.messaging.activemq.deployment.DefaultJMSConnectionFactoryBindingProcessor) MessagingXmlParsingDeploymentUnitProcessor(org.wildfly.extension.messaging.activemq.deployment.MessagingXmlParsingDeploymentUnitProcessor) BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration) OperationContext(org.jboss.as.controller.OperationContext) MessagingDependencyProcessor(org.wildfly.extension.messaging.activemq.deployment.MessagingDependencyProcessor) CDIDeploymentProcessor(org.wildfly.extension.messaging.activemq.deployment.injection.CDIDeploymentProcessor) JMSDestinationDefinitionDescriptorProcessor(org.wildfly.extension.messaging.activemq.deployment.JMSDestinationDefinitionDescriptorProcessor) MessagingXmlInstallDeploymentUnitProcessor(org.wildfly.extension.messaging.activemq.deployment.MessagingXmlInstallDeploymentUnitProcessor) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) ServiceTarget(org.jboss.msc.service.ServiceTarget) OperationFailedException(org.jboss.as.controller.OperationFailedException) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) DeploymentProcessorTarget(org.jboss.as.server.DeploymentProcessorTarget) ServiceName(org.jboss.msc.service.ServiceName) JMSDestinationDefinitionAnnotationProcessor(org.wildfly.extension.messaging.activemq.deployment.JMSDestinationDefinitionAnnotationProcessor) AbstractDeploymentChainStep(org.jboss.as.server.AbstractDeploymentChainStep) ModelNode(org.jboss.dmr.ModelNode) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)61 UDPBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory)32 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)19 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)19 BroadcastEndpointFactory (org.apache.activemq.artemis.api.core.BroadcastEndpointFactory)18 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)14 JGroupsFileBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory)12 JGroupsPropertiesBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory)10 HashMap (java.util.HashMap)9 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)9 URI (java.net.URI)7 BroadcastGroupConfiguration (org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration)7 Map (java.util.Map)6 ChannelBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory)5 ClusterConnectionConfiguration (org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration)5 HashSet (java.util.HashSet)4 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)4 Before (org.junit.Before)4 Hashtable (java.util.Hashtable)3