Search in sources :

Example 1 with BroadcastCommandDispatcherFactory

use of org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory in project wildfly by wildfly.

the class ExternalPooledConnectionFactoryService method installService0.

private static void installService0(OperationContext context, ServiceName serviceName, ExternalPooledConnectionFactoryService service, DiscoveryGroupConfiguration groupConfiguration, Set<String> connectorsSocketBindings, ModelNode model) throws OperationFailedException {
    ServiceBuilder<?> serviceBuilder = context.getServiceTarget().addService(serviceName);
    serviceBuilder.requires(context.getCapabilityServiceName(MessagingServices.LOCAL_TRANSACTION_PROVIDER_CAPABILITY, null));
    // ensures that Artemis client thread pools are not stopped before any deployment depending on a pooled-connection-factory
    serviceBuilder.requires(MessagingServices.ACTIVEMQ_CLIENT_THREAD_POOL);
    ModelNode credentialReference = ConnectionFactoryAttributes.Pooled.CREDENTIAL_REFERENCE.resolveModelAttribute(context, model);
    if (credentialReference.isDefined()) {
        service.credentialSourceSupplier = CredentialReference.getCredentialSourceSupplier(context, ConnectionFactoryAttributes.Pooled.CREDENTIAL_REFERENCE, model, serviceBuilder);
    }
    Map<String, Boolean> outbounds = TransportConfigOperationHandlers.listOutBoundSocketBinding(context, connectorsSocketBindings);
    for (final String connectorSocketBinding : connectorsSocketBindings) {
        // find whether the connectorSocketBinding references a SocketBinding or an OutboundSocketBinding
        if (outbounds.get(connectorSocketBinding)) {
            final ServiceName outboundSocketName = OutboundSocketBinding.OUTBOUND_SOCKET_BINDING_BASE_SERVICE_NAME.append(connectorSocketBinding);
            Supplier<OutboundSocketBinding> outboundSocketBindingSupplier = serviceBuilder.requires(outboundSocketName);
            service.outboundSocketBindings.put(connectorSocketBinding, outboundSocketBindingSupplier);
        } else {
            final ServiceName socketName = SocketBinding.JBOSS_BINDING_NAME.append(connectorSocketBinding);
            Supplier<SocketBinding> socketBindingSupplier = serviceBuilder.requires(socketName);
            service.socketBindings.put(connectorSocketBinding, socketBindingSupplier);
        }
    }
    if (groupConfiguration != null) {
        final String key = "discovery" + groupConfiguration.getName();
        if (service.jgroupsClusterName != null) {
            Supplier<BroadcastCommandDispatcherFactory> commandDispatcherFactorySupplier = serviceBuilder.requires(MessagingServices.getBroadcastCommandDispatcherFactoryServiceName(service.jgroupsChannelName));
            service.commandDispatcherFactories.put(key, commandDispatcherFactorySupplier);
            service.clusterNames.put(key, service.jgroupsClusterName);
        } else {
            final ServiceName groupBinding = GroupBindingService.getDiscoveryBaseServiceName(JBOSS_MESSAGING_ACTIVEMQ).append(groupConfiguration.getName());
            Supplier<SocketBinding> socketBindingSupplier = serviceBuilder.requires(groupBinding);
            service.groupBindings.put(key, socketBindingSupplier);
        }
    }
    serviceBuilder.setInstance(service);
    serviceBuilder.install();
}
Also used : OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) SocketBinding(org.jboss.as.network.SocketBinding) OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) ServiceName(org.jboss.msc.service.ServiceName) BroadcastCommandDispatcherFactory(org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory) XsdString(org.jboss.jca.common.api.metadata.spec.XsdString) LocalizedXsdString(org.jboss.jca.common.api.metadata.spec.LocalizedXsdString) ModelNode(org.jboss.dmr.ModelNode)

Example 2 with BroadcastCommandDispatcherFactory

use of org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory in project wildfly by wildfly.

the class ExternalConnectionFactoryService method start.

@Override
public void start(StartContext context) throws StartException {
    try {
        if (connectors != null && connectors.length > 0) {
            TransportConfigOperationHandlers.processConnectorBindings(Arrays.asList(connectors), socketBindings, outboundSocketBindings);
            if (ha) {
                factory = ActiveMQJMSClient.createConnectionFactoryWithHA(type, connectors);
            } else {
                factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(type, connectors);
            }
        } else {
            final String name = groupConfiguration.getName();
            final String key = "discovery" + name;
            final DiscoveryGroupConfiguration config;
            if (commandDispatcherFactories.containsKey(key)) {
                BroadcastCommandDispatcherFactory commandDispatcherFactory = commandDispatcherFactories.get(key).get();
                String clusterName = clusterNames.get(key);
                config = JGroupsDiscoveryGroupAdd.createDiscoveryGroupConfiguration(name, groupConfiguration, commandDispatcherFactory, clusterName);
            } else {
                final SocketBinding binding = groupBindings.get(key).get();
                if (binding == null) {
                    throw MessagingLogger.ROOT_LOGGER.failedToFindDiscoverySocketBinding(name);
                }
                config = SocketDiscoveryGroupAdd.createDiscoveryGroupConfiguration(name, groupConfiguration, binding);
                binding.getSocketBindings().getNamedRegistry().registerBinding(ManagedBinding.Factory.createSimpleManagedBinding(binding));
            }
            if (ha) {
                factory = ActiveMQJMSClient.createConnectionFactoryWithHA(config, type);
            } else {
                factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(config, type);
            }
        }
        if (config != null) {
            factory.setAutoGroup(config.isAutoGroup());
            factory.setBlockOnAcknowledge(config.isBlockOnAcknowledge());
            factory.setBlockOnDurableSend(config.isBlockOnDurableSend());
            factory.setBlockOnNonDurableSend(config.isBlockOnNonDurableSend());
            factory.setCacheLargeMessagesClient(config.isCacheLargeMessagesClient());
            factory.setCallFailoverTimeout(config.getCallFailoverTimeout());
            factory.setCallTimeout(config.getCallTimeout());
            factory.setClientID(config.getClientID());
            factory.setClientFailureCheckPeriod(config.getClientFailureCheckPeriod());
            factory.setCompressLargeMessage(config.isCompressLargeMessages());
            factory.setConfirmationWindowSize(config.getConfirmationWindowSize());
            factory.setConnectionTTL(config.getConnectionTTL());
            factory.setConsumerMaxRate(config.getConsumerMaxRate());
            factory.setConsumerWindowSize(config.getConsumerWindowSize());
            factory.setDeserializationBlackList(config.getDeserializationBlackList());
            factory.setDeserializationWhiteList(config.getDeserializationWhiteList());
            factory.setDupsOKBatchSize(config.getDupsOKBatchSize());
            factory.setEnableSharedClientID(config.isEnableSharedClientID());
            factory.setFailoverOnInitialConnection(config.isFailoverOnInitialConnection());
            factory.setGroupID(config.getGroupID());
            factory.setInitialMessagePacketSize(config.getInitialMessagePacketSize());
            factory.setMaxRetryInterval(config.getMaxRetryInterval());
            factory.setMinLargeMessageSize(config.getMinLargeMessageSize());
            factory.setPreAcknowledge(config.isPreAcknowledge());
            factory.setProducerMaxRate(config.getProducerMaxRate());
            factory.setProducerWindowSize(config.getProducerWindowSize());
            factory.setProtocolManagerFactoryStr(config.getProtocolManagerFactoryStr());
            factory.setConnectionLoadBalancingPolicyClassName(config.getLoadBalancingPolicyClassName());
            factory.setReconnectAttempts(config.getReconnectAttempts());
            factory.setRetryInterval(config.getRetryInterval());
            factory.setRetryIntervalMultiplier(config.getRetryIntervalMultiplier());
            factory.setScheduledThreadPoolMaxSize(config.getScheduledThreadPoolMaxSize());
            factory.setThreadPoolMaxSize(config.getThreadPoolMaxSize());
            factory.setTransactionBatchSize(config.getTransactionBatchSize());
            factory.setUseGlobalPools(config.isUseGlobalPools());
            factory.setUseTopologyForLoadBalancing(config.getUseTopologyForLoadBalancing());
        }
        factory.setEnable1xPrefixes(enable1Prefixes);
    } catch (Throwable e) {
        throw MessagingLogger.ROOT_LOGGER.failedToCreate(e, "connection-factory");
    }
}
Also used : OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) SocketBinding(org.jboss.as.network.SocketBinding) BroadcastCommandDispatcherFactory(org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)

Example 3 with BroadcastCommandDispatcherFactory

use of org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory in project wildfly by wildfly.

the class ActiveMQServerService method start.

@Override
public synchronized void start(final StartContext context) throws StartException {
    ClassLoader origTCCL = org.wildfly.security.manager.WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    // Validate whether the AIO native layer can be used
    JournalType jtype = configuration.getJournalType();
    if (jtype == JournalType.ASYNCIO) {
        boolean supportsAIO = AIOSequentialFileFactory.isSupported();
        if (supportsAIO == false) {
            String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
            if (osName.contains("nux")) {
                ROOT_LOGGER.aioInfoLinux();
            } else {
                ROOT_LOGGER.aioInfo();
            }
            configuration.setJournalType(JournalType.NIO);
        }
    }
    // Setup paths
    configuration.setBindingsDirectory(pathConfig.resolveBindingsPath(pathManager.get()));
    configuration.setLargeMessagesDirectory(pathConfig.resolveLargeMessagePath(pathManager.get()));
    configuration.setJournalDirectory(pathConfig.resolveJournalPath(pathManager.get()));
    configuration.setPagingDirectory(pathConfig.resolvePagingPath(pathManager.get()));
    pathConfig.registerCallbacks(pathManager.get());
    try {
        // Update the acceptor/connector port/host values from the
        // Map the socket bindings onto the connectors/acceptors
        Collection<TransportConfiguration> acceptors = configuration.getAcceptorConfigurations();
        Collection<TransportConfiguration> connectors = configuration.getConnectorConfigurations().values();
        Collection<BroadcastGroupConfiguration> broadcastGroups = configuration.getBroadcastGroupConfigurations();
        Map<String, DiscoveryGroupConfiguration> discoveryGroups = configuration.getDiscoveryGroupConfigurations();
        TransportConfigOperationHandlers.processConnectorBindings(connectors, socketBindings, outboundSocketBindings);
        if (acceptors != null) {
            for (TransportConfiguration tc : acceptors) {
                // If there is a socket binding set the HOST/PORT values
                Object socketRef = tc.getParams().remove(SOCKET_REF);
                if (socketRef != null) {
                    String name = socketRef.toString();
                    SocketBinding binding = socketBindings.get(name).get();
                    if (binding == null) {
                        throw MessagingLogger.ROOT_LOGGER.failedToFindConnectorSocketBinding(tc.getName());
                    }
                    binding.getSocketBindings().getNamedRegistry().registerBinding(ManagedBinding.Factory.createSimpleManagedBinding(binding));
                    InetSocketAddress socketAddress = binding.getSocketAddress();
                    tc.getParams().put(HOST, socketAddress.getAddress().getHostAddress());
                    tc.getParams().put(PORT, socketAddress.getPort());
                }
            }
        }
        if (broadcastGroups != null) {
            final List<BroadcastGroupConfiguration> newConfigs = new ArrayList<>();
            for (final BroadcastGroupConfiguration config : broadcastGroups) {
                final String name = config.getName();
                final String key = "broadcast" + name;
                if (commandDispatcherFactories.containsKey(key)) {
                    BroadcastCommandDispatcherFactory commandDispatcherFactory = commandDispatcherFactories.get(key).get();
                    String clusterName = clusterNames.get(key);
                    newConfigs.add(JGroupsBroadcastGroupAdd.createBroadcastGroupConfiguration(name, config, commandDispatcherFactory, clusterName));
                } else {
                    final Supplier<SocketBinding> bindingSupplier = groupBindings.get(key);
                    if (bindingSupplier == null) {
                        throw MessagingLogger.ROOT_LOGGER.failedToFindBroadcastSocketBinding(name);
                    }
                    final SocketBinding binding = bindingSupplier.get();
                    binding.getSocketBindings().getNamedRegistry().registerBinding(ManagedBinding.Factory.createSimpleManagedBinding(binding));
                    newConfigs.add(SocketBroadcastGroupAdd.createBroadcastGroupConfiguration(name, config, binding));
                }
            }
            configuration.getBroadcastGroupConfigurations().clear();
            configuration.getBroadcastGroupConfigurations().addAll(newConfigs);
        }
        if (discoveryGroups != null) {
            configuration.setDiscoveryGroupConfigurations(new HashMap<>());
            for (final Map.Entry<String, DiscoveryGroupConfiguration> entry : discoveryGroups.entrySet()) {
                final String name = entry.getKey();
                final String key = "discovery" + name;
                final DiscoveryGroupConfiguration config;
                if (commandDispatcherFactories.containsKey(key)) {
                    BroadcastCommandDispatcherFactory commandDispatcherFactory = commandDispatcherFactories.get(key).get();
                    String clusterName = clusterNames.get(key);
                    config = JGroupsDiscoveryGroupAdd.createDiscoveryGroupConfiguration(name, entry.getValue(), commandDispatcherFactory, clusterName);
                } else {
                    final Supplier<SocketBinding> binding = groupBindings.get(key);
                    if (binding == null) {
                        throw MessagingLogger.ROOT_LOGGER.failedToFindDiscoverySocketBinding(name);
                    }
                    config = SocketDiscoveryGroupAdd.createDiscoveryGroupConfiguration(name, entry.getValue(), binding.get());
                    binding.get().getSocketBindings().getNamedRegistry().registerBinding(ManagedBinding.Factory.createSimpleManagedBinding(binding.get()));
                }
                configuration.getDiscoveryGroupConfigurations().put(name, config);
            }
        }
        // security - if an Elytron domain has been defined we delegate security checks to the Elytron based security manager.
        final ActiveMQSecurityManager securityManager;
        if (configuration.isSecurityEnabled()) {
            if (elytronSecurityDomain.isPresent()) {
                securityManager = new ElytronSecurityManager(elytronSecurityDomain.get().get());
            } else {
                securityManager = new WildFlySecurityManager();
            }
        } else {
            securityManager = null;
        }
        // insert possible credential source hold passwords
        setBridgePasswordsFromCredentialSource();
        setClusterPasswordFromCredentialSource();
        if (dataSource.isPresent()) {
            final DataSource ds = dataSource.get().get();
            DatabaseStorageConfiguration dbConfiguration = (DatabaseStorageConfiguration) configuration.getStoreConfiguration();
            dbConfiguration.setDataSource(ds);
            // inject the datasource into the PropertySQLProviderFactory to be able to determine the
            // type of database for the datasource metadata
            PropertySQLProvider.Factory sqlProviderFactory = new PropertySQLProvider.Factory(ds);
            dbConfiguration.setSqlProvider(sqlProviderFactory);
            configuration.setStoreConfiguration(dbConfiguration);
            ROOT_LOGGER.infof("use JDBC store for Artemis server, bindingsTable:%s", dbConfiguration.getBindingsTableName());
        }
        final MBeanServer mbs = mbeanServer.isPresent() ? mbeanServer.get().get() : null;
        // Now start the server
        server = new ActiveMQServerImpl(configuration, mbs, securityManager);
        if (ServerDefinition.CLUSTER_PASSWORD.getDefaultValue().asString().equals(server.getConfiguration().getClusterPassword())) {
            server.getConfiguration().setClusterPassword(java.util.UUID.randomUUID().toString());
        }
        for (Interceptor incomingInterceptor : incomingInterceptors) {
            server.getServiceRegistry().addIncomingInterceptor(incomingInterceptor);
        }
        for (Interceptor outgoingInterceptor : outgoingInterceptors) {
            server.getServiceRegistry().addOutgoingInterceptor(outgoingInterceptor);
        }
    // the server is actually started by the Jakarta Messaging Service.
    } catch (Exception e) {
        throw MessagingLogger.ROOT_LOGGER.failedToStartService(e);
    } finally {
        org.wildfly.security.manager.WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(origTCCL);
    }
}
Also used : OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) SocketBinding(org.jboss.as.network.SocketBinding) BroadcastCommandDispatcherFactory(org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory) InetSocketAddress(java.net.InetSocketAddress) ArrayList(java.util.ArrayList) AIOSequentialFileFactory(org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory) BroadcastCommandDispatcherFactory(org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration) ActiveMQSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager) Interceptor(org.apache.activemq.artemis.api.core.Interceptor) MBeanServer(javax.management.MBeanServer) PropertySQLProvider(org.apache.activemq.artemis.jdbc.store.sql.PropertySQLProvider) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) StartException(org.jboss.msc.service.StartException) DataSource(javax.sql.DataSource) DatabaseStorageConfiguration(org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration) JournalType(org.apache.activemq.artemis.core.server.JournalType) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with BroadcastCommandDispatcherFactory

use of org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory in project wildfly by wildfly.

the class ExternalPooledConnectionFactoryService method createService.

private void createService(ServiceTarget serviceTarget, ServiceContainer container) throws Exception {
    InputStream is = null;
    InputStream isIj = null;
    // Properties for the resource adapter
    List<ConfigProperty> properties = new ArrayList<ConfigProperty>();
    try {
        StringBuilder connectorClassname = new StringBuilder();
        StringBuilder connectorParams = new StringBuilder();
        TransportConfigOperationHandlers.processConnectorBindings(Arrays.asList(connectors), socketBindings, outboundSocketBindings);
        for (TransportConfiguration tc : connectors) {
            if (tc == null) {
                throw MessagingLogger.ROOT_LOGGER.connectorNotDefined("null");
            }
            if (connectorClassname.length() > 0) {
                connectorClassname.append(",");
                connectorParams.append(",");
            }
            connectorClassname.append(tc.getFactoryClassName());
            Map<String, Object> params = tc.getParams();
            boolean multiple = false;
            for (Map.Entry<String, Object> entry : params.entrySet()) {
                if (multiple) {
                    connectorParams.append(";");
                }
                connectorParams.append(entry.getKey()).append("=").append(entry.getValue());
                multiple = true;
            }
        }
        if (connectorClassname.length() > 0) {
            properties.add(simpleProperty15(CONNECTOR_CLASSNAME, STRING_TYPE, connectorClassname.toString()));
        }
        if (connectorParams.length() > 0) {
            properties.add(simpleProperty15(CONNECTION_PARAMETERS, STRING_TYPE, connectorParams.toString()));
        }
        if (discoveryGroupConfiguration != null) {
            final String dgName = discoveryGroupConfiguration.getName();
            final String key = "discovery" + dgName;
            final DiscoveryGroupConfiguration config;
            if (commandDispatcherFactories.containsKey(key)) {
                BroadcastCommandDispatcherFactory commandDispatcherFactory = commandDispatcherFactories.get(key).get();
                String clusterName = clusterNames.get(key);
                config = JGroupsDiscoveryGroupAdd.createDiscoveryGroupConfiguration(name, discoveryGroupConfiguration, commandDispatcherFactory, clusterName);
            } else {
                final SocketBinding binding = groupBindings.get(key).get();
                if (binding == null) {
                    throw MessagingLogger.ROOT_LOGGER.failedToFindDiscoverySocketBinding(dgName);
                }
                config = SocketDiscoveryGroupAdd.createDiscoveryGroupConfiguration(name, discoveryGroupConfiguration, binding);
                binding.getSocketBindings().getNamedRegistry().registerBinding(ManagedBinding.Factory.createSimpleManagedBinding(binding));
            }
            BroadcastEndpointFactory bgCfg = config.getBroadcastEndpointFactory();
            if (bgCfg instanceof UDPBroadcastEndpointFactory) {
                UDPBroadcastEndpointFactory udpCfg = (UDPBroadcastEndpointFactory) bgCfg;
                properties.add(simpleProperty15(GROUP_ADDRESS, STRING_TYPE, udpCfg.getGroupAddress()));
                properties.add(simpleProperty15(GROUP_PORT, INTEGER_TYPE, "" + udpCfg.getGroupPort()));
                properties.add(simpleProperty15(DISCOVERY_LOCAL_BIND_ADDRESS, STRING_TYPE, "" + udpCfg.getLocalBindAddress()));
            } else if (bgCfg instanceof CommandDispatcherBroadcastEndpointFactory) {
                String external = "/" + name + ":discovery" + dgName;
                properties.add(simpleProperty15(JGROUPS_CHANNEL_NAME, STRING_TYPE, jgroupsClusterName));
                properties.add(simpleProperty15(JGROUPS_CHANNEL_REF_NAME, STRING_TYPE, external));
            }
            properties.add(simpleProperty15(DISCOVERY_INITIAL_WAIT_TIMEOUT, LONG_TYPE, "" + config.getDiscoveryInitialWaitTimeout()));
            properties.add(simpleProperty15(REFRESH_TIMEOUT, LONG_TYPE, "" + config.getRefreshTimeout()));
        }
        boolean hasReconnect = false;
        final List<ConfigProperty> inboundProperties = new ArrayList<>();
        final List<ConfigProperty> outboundProperties = new ArrayList<>();
        final String reconnectName = ConnectionFactoryAttributes.Pooled.RECONNECT_ATTEMPTS_PROP_NAME;
        for (PooledConnectionFactoryConfigProperties adapterParam : adapterParams) {
            hasReconnect |= reconnectName.equals(adapterParam.getName());
            ConfigProperty p = simpleProperty15(adapterParam.getName(), adapterParam.getType(), adapterParam.getValue());
            if (adapterParam.getName().equals(REBALANCE_CONNECTIONS_PROP_NAME)) {
                boolean rebalanceConnections = Boolean.parseBoolean(adapterParam.getValue());
                if (rebalanceConnections) {
                    inboundProperties.add(p);
                }
            } else {
                if (null == adapterParam.getConfigType()) {
                    properties.add(p);
                } else {
                    switch(adapterParam.getConfigType()) {
                        case INBOUND:
                            inboundProperties.add(p);
                            break;
                        case OUTBOUND:
                            outboundProperties.add(p);
                            break;
                        default:
                            properties.add(p);
                            break;
                    }
                }
            }
        }
        // The default -1, which will hang forever until a server appears
        if (!hasReconnect) {
            properties.add(simpleProperty15(reconnectName, Integer.class.getName(), DEFAULT_MAX_RECONNECTS));
        }
        configureCredential(properties);
        WildFlyRecoveryRegistry.container = container;
        OutboundResourceAdapter outbound = createOutbound(outboundProperties);
        InboundResourceAdapter inbound = createInbound(inboundProperties);
        ResourceAdapter ra = createResourceAdapter15(properties, outbound, inbound);
        Connector cmd = createConnector15(ra);
        TransactionSupportEnum transactionSupport = getTransactionSupport(txSupport);
        ConnectionDefinition common = createConnDef(transactionSupport, bindInfo.getBindName(), minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace);
        Activation activation = createActivation(common, transactionSupport);
        ResourceAdapterActivatorService activator = new ResourceAdapterActivatorService(cmd, activation, ExternalPooledConnectionFactoryService.class.getClassLoader(), name);
        activator.setBindInfo(bindInfo);
        activator.setCreateBinderService(createBinderService);
        activator.addJndiAliases(jndiAliases);
        final ServiceBuilder sb = Services.addServerExecutorDependency(serviceTarget.addService(getResourceAdapterActivatorsServiceName(name), activator), activator.getExecutorServiceInjector()).addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class, activator.getMdrInjector()).addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, activator.getRaRepositoryInjector()).addDependency(ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE, ManagementRepository.class, activator.getManagementRepositoryInjector()).addDependency(ConnectorServices.RESOURCE_ADAPTER_REGISTRY_SERVICE, ResourceAdapterDeploymentRegistry.class, activator.getRegistryInjector()).addDependency(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE, TransactionIntegration.class, activator.getTxIntegrationInjector()).addDependency(ConnectorServices.CONNECTOR_CONFIG_SERVICE, JcaSubsystemConfiguration.class, activator.getConfigInjector()).addDependency(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class, activator.getCcmInjector());
        sb.requires(NamingService.SERVICE_NAME);
        sb.requires(capabilityServiceSupport.getCapabilityServiceName(MessagingServices.LOCAL_TRANSACTION_PROVIDER_CAPABILITY));
        sb.requires(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append("default"));
        sb.setInitialMode(ServiceController.Mode.PASSIVE).install();
        // Mock the deployment service to allow it to start
        serviceTarget.addService(ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(name), Service.NULL).install();
    } finally {
        if (is != null) {
            is.close();
        }
        if (isIj != null) {
            isIj.close();
        }
    }
}
Also used : OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) SocketBinding(org.jboss.as.network.SocketBinding) Connector(org.jboss.jca.common.api.metadata.spec.Connector) ConnectionDefinition(org.jboss.jca.common.api.metadata.resourceadapter.ConnectionDefinition) BroadcastCommandDispatcherFactory(org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory) JcaSubsystemConfiguration(org.jboss.as.connector.subsystems.jca.JcaSubsystemConfiguration) ArrayList(java.util.ArrayList) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Activation(org.jboss.jca.common.api.metadata.resourceadapter.Activation) XsdString(org.jboss.jca.common.api.metadata.spec.XsdString) LocalizedXsdString(org.jboss.jca.common.api.metadata.spec.LocalizedXsdString) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) ResourceAdapter(org.jboss.jca.common.api.metadata.spec.ResourceAdapter) InboundResourceAdapter(org.jboss.jca.common.api.metadata.spec.InboundResourceAdapter) OutboundResourceAdapter(org.jboss.jca.common.api.metadata.spec.OutboundResourceAdapter) ActiveMQResourceAdapter(org.wildfly.extension.messaging.activemq.ActiveMQResourceAdapter) ResourceAdapterRepository(org.jboss.jca.core.spi.rar.ResourceAdapterRepository) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) ResourceAdapterDeploymentRegistry(org.jboss.as.connector.services.resourceadapters.deployment.registry.ResourceAdapterDeploymentRegistry) InboundResourceAdapter(org.jboss.jca.common.api.metadata.spec.InboundResourceAdapter) InputStream(java.io.InputStream) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) CommandDispatcherBroadcastEndpointFactory(org.wildfly.extension.messaging.activemq.broadcast.CommandDispatcherBroadcastEndpointFactory) ResourceAdapterActivatorService(org.jboss.as.connector.services.resourceadapters.ResourceAdapterActivatorService) ConfigProperty(org.jboss.jca.common.api.metadata.spec.ConfigProperty) RequiredConfigProperty(org.jboss.jca.common.api.metadata.spec.RequiredConfigProperty) AdminObject(org.jboss.jca.common.api.metadata.resourceadapter.AdminObject) TransactionSupportEnum(org.jboss.jca.common.api.metadata.common.TransactionSupportEnum) Map(java.util.Map) HashMap(java.util.HashMap) OutboundResourceAdapter(org.jboss.jca.common.api.metadata.spec.OutboundResourceAdapter) CommandDispatcherBroadcastEndpointFactory(org.wildfly.extension.messaging.activemq.broadcast.CommandDispatcherBroadcastEndpointFactory) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) BroadcastEndpointFactory(org.apache.activemq.artemis.api.core.BroadcastEndpointFactory)

Example 5 with BroadcastCommandDispatcherFactory

use of org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory in project wildfly by wildfly.

the class ExternalPooledConnectionFactoryService method installService0.

private static void installService0(ServiceBuilder<?> serviceBuilder, ExternalBrokerConfigurationService configuration, ExternalPooledConnectionFactoryService service, DiscoveryGroupConfiguration groupConfiguration, Set<String> connectorsSocketBindings, CapabilityServiceSupport capabilityServiceSupport) throws OperationFailedException {
    serviceBuilder.requires(capabilityServiceSupport.getCapabilityServiceName(MessagingServices.LOCAL_TRANSACTION_PROVIDER_CAPABILITY));
    // ensures that Artemis client thread pools are not stopped before any deployment depending on a pooled-connection-factory
    serviceBuilder.requires(MessagingServices.ACTIVEMQ_CLIENT_THREAD_POOL);
    Map<String, ServiceName> outbounds = configuration.getOutboundSocketBindings();
    for (final String connectorSocketBinding : connectorsSocketBindings) {
        // find whether the connectorSocketBinding references a SocketBinding or an OutboundSocketBinding
        if (outbounds.containsKey(connectorSocketBinding)) {
            Supplier<OutboundSocketBinding> outboundSocketBindingSupplier = serviceBuilder.requires(configuration.getOutboundSocketBindings().get(connectorSocketBinding));
            service.outboundSocketBindings.put(connectorSocketBinding, outboundSocketBindingSupplier);
        } else {
            Supplier<SocketBinding> socketBindingSupplier = serviceBuilder.requires(configuration.getSocketBindings().get(connectorSocketBinding));
            service.socketBindings.put(connectorSocketBinding, socketBindingSupplier);
        }
    }
    if (groupConfiguration != null) {
        final String key = "discovery" + groupConfiguration.getName();
        if (service.jgroupsClusterName != null) {
            Supplier<BroadcastCommandDispatcherFactory> commandDispatcherFactorySupplier = serviceBuilder.requires(configuration.getCommandDispatcherFactories().get(key));
            service.commandDispatcherFactories.put(key, commandDispatcherFactorySupplier);
            service.clusterNames.put(key, service.jgroupsClusterName);
        } else {
            Supplier<SocketBinding> socketBindingSupplier = serviceBuilder.requires(configuration.getGroupBindings().get(key));
            service.groupBindings.put(key, socketBindingSupplier);
        }
    }
    serviceBuilder.setInstance(service);
    serviceBuilder.install();
}
Also used : OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) SocketBinding(org.jboss.as.network.SocketBinding) OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) ServiceName(org.jboss.msc.service.ServiceName) BroadcastCommandDispatcherFactory(org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory) XsdString(org.jboss.jca.common.api.metadata.spec.XsdString) LocalizedXsdString(org.jboss.jca.common.api.metadata.spec.LocalizedXsdString)

Aggregations

OutboundSocketBinding (org.jboss.as.network.OutboundSocketBinding)6 SocketBinding (org.jboss.as.network.SocketBinding)6 BroadcastCommandDispatcherFactory (org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory)6 HashMap (java.util.HashMap)3 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)3 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)3 LocalizedXsdString (org.jboss.jca.common.api.metadata.spec.LocalizedXsdString)3 XsdString (org.jboss.jca.common.api.metadata.spec.XsdString)3 ServiceName (org.jboss.msc.service.ServiceName)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ModelNode (org.jboss.dmr.ModelNode)2 InputStream (java.io.InputStream)1 InetSocketAddress (java.net.InetSocketAddress)1 HashSet (java.util.HashSet)1 Supplier (java.util.function.Supplier)1 MBeanServer (javax.management.MBeanServer)1 DataSource (javax.sql.DataSource)1 BroadcastEndpointFactory (org.apache.activemq.artemis.api.core.BroadcastEndpointFactory)1 BroadcastGroupConfiguration (org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration)1