Search in sources :

Example 1 with ConnectorServiceConfiguration

use of org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration in project activemq-artemis by apache.

the class FileConfigurationParser method parseMainConfig.

public void parseMainConfig(final Element e, final Configuration config) throws Exception {
    config.setName(getString(e, "name", config.getName(), Validators.NO_CHECK));
    config.setSystemPropertyPrefix(getString(e, "system-property-prefix", config.getSystemPropertyPrefix(), Validators.NOT_NULL_OR_EMPTY));
    NodeList haPolicyNodes = e.getElementsByTagName("ha-policy");
    if (haPolicyNodes.getLength() > 0) {
        parseHAPolicyConfiguration((Element) haPolicyNodes.item(0), config);
    }
    // if we aren already set then set to default
    if (config.getHAPolicyConfiguration() == null) {
        config.setHAPolicyConfiguration(new LiveOnlyPolicyConfiguration());
    }
    NodeList storeTypeNodes = e.getElementsByTagName("store");
    if (storeTypeNodes.getLength() > 0) {
        parseStoreConfiguration((Element) storeTypeNodes.item(0), config);
    }
    config.setResolveProtocols(getBoolean(e, "resolve-protocols", config.isResolveProtocols()));
    config.setPersistenceEnabled(getBoolean(e, "persistence-enabled", config.isPersistenceEnabled()));
    config.setPersistDeliveryCountBeforeDelivery(getBoolean(e, "persist-delivery-count-before-delivery", config.isPersistDeliveryCountBeforeDelivery()));
    config.setScheduledThreadPoolMaxSize(getInteger(e, "scheduled-thread-pool-max-size", config.getScheduledThreadPoolMaxSize(), Validators.GT_ZERO));
    config.setThreadPoolMaxSize(getInteger(e, "thread-pool-max-size", config.getThreadPoolMaxSize(), Validators.MINUS_ONE_OR_GT_ZERO));
    config.setSecurityEnabled(getBoolean(e, "security-enabled", config.isSecurityEnabled()));
    config.setGracefulShutdownEnabled(getBoolean(e, "graceful-shutdown-enabled", config.isGracefulShutdownEnabled()));
    config.setGracefulShutdownTimeout(getLong(e, "graceful-shutdown-timeout", config.getGracefulShutdownTimeout(), Validators.MINUS_ONE_OR_GE_ZERO));
    config.setJMXManagementEnabled(getBoolean(e, "jmx-management-enabled", config.isJMXManagementEnabled()));
    config.setJMXDomain(getString(e, "jmx-domain", config.getJMXDomain(), Validators.NOT_NULL_OR_EMPTY));
    config.setJMXUseBrokerName(getBoolean(e, "jmx-use-broker-name", config.isJMXUseBrokerName()));
    config.setSecurityInvalidationInterval(getLong(e, "security-invalidation-interval", config.getSecurityInvalidationInterval(), Validators.GT_ZERO));
    config.setConnectionTTLOverride(getLong(e, "connection-ttl-override", config.getConnectionTTLOverride(), Validators.MINUS_ONE_OR_GT_ZERO));
    config.setEnabledAsyncConnectionExecution(getBoolean(e, "async-connection-execution-enabled", config.isAsyncConnectionExecutionEnabled()));
    config.setTransactionTimeout(getLong(e, "transaction-timeout", config.getTransactionTimeout(), Validators.GT_ZERO));
    config.setTransactionTimeoutScanPeriod(getLong(e, "transaction-timeout-scan-period", config.getTransactionTimeoutScanPeriod(), Validators.GT_ZERO));
    config.setMessageExpiryScanPeriod(getLong(e, "message-expiry-scan-period", config.getMessageExpiryScanPeriod(), Validators.MINUS_ONE_OR_GT_ZERO));
    config.setMessageExpiryThreadPriority(getInteger(e, "message-expiry-thread-priority", config.getMessageExpiryThreadPriority(), Validators.THREAD_PRIORITY_RANGE));
    config.setIDCacheSize(getInteger(e, "id-cache-size", config.getIDCacheSize(), Validators.GT_ZERO));
    config.setPersistIDCache(getBoolean(e, "persist-id-cache", config.isPersistIDCache()));
    config.setManagementAddress(new SimpleString(getString(e, "management-address", config.getManagementAddress().toString(), Validators.NOT_NULL_OR_EMPTY)));
    config.setManagementNotificationAddress(new SimpleString(getString(e, "management-notification-address", config.getManagementNotificationAddress().toString(), Validators.NOT_NULL_OR_EMPTY)));
    config.setMaskPassword(getBoolean(e, "mask-password", null));
    config.setPasswordCodec(getString(e, "password-codec", DefaultSensitiveStringCodec.class.getName(), Validators.NOT_NULL_OR_EMPTY));
    config.setPopulateValidatedUser(getBoolean(e, "populate-validated-user", config.isPopulateValidatedUser()));
    config.setConnectionTtlCheckInterval(getLong(e, "connection-ttl-check-interval", config.getConnectionTtlCheckInterval(), Validators.GT_ZERO));
    config.setConfigurationFileRefreshPeriod(getLong(e, "configuration-file-refresh-period", config.getConfigurationFileRefreshPeriod(), Validators.GT_ZERO));
    long globalMaxSize = getTextBytesAsLongBytes(e, GLOBAL_MAX_SIZE, -1, Validators.MINUS_ONE_OR_GT_ZERO);
    if (globalMaxSize > 0) {
        // We only set it if it's not set on the XML, otherwise getGlobalMaxSize will calculate it.
        // We do it this way because it will be valid also on the case of embedded
        config.setGlobalMaxSize(globalMaxSize);
    }
    config.setMaxDiskUsage(getInteger(e, MAX_DISK_USAGE, config.getMaxDiskUsage(), Validators.PERCENTAGE_OR_MINUS_ONE));
    config.setDiskScanPeriod(getInteger(e, DISK_SCAN_PERIOD, config.getDiskScanPeriod(), Validators.MINUS_ONE_OR_GT_ZERO));
    config.setInternalNamingPrefix(getString(e, INTERNAL_NAMING_PREFIX, config.getInternalNamingPrefix(), Validators.NO_CHECK));
    config.setAmqpUseCoreSubscriptionNaming(getBoolean(e, AMQP_USE_CORE_SUBSCRIPTION_NAMING, config.isAmqpUseCoreSubscriptionNaming()));
    // parsing cluster password
    String passwordText = getString(e, "cluster-password", null, Validators.NO_CHECK);
    final Boolean maskText = config.isMaskPassword();
    if (passwordText != null) {
        String resolvedPassword = PasswordMaskingUtil.resolveMask(maskText, passwordText, config.getPasswordCodec());
        config.setClusterPassword(resolvedPassword);
    }
    config.setClusterUser(getString(e, "cluster-user", config.getClusterUser(), Validators.NO_CHECK));
    NodeList interceptorNodes = e.getElementsByTagName("remoting-interceptors");
    ArrayList<String> incomingInterceptorList = new ArrayList<>();
    if (interceptorNodes.getLength() > 0) {
        NodeList interceptors = interceptorNodes.item(0).getChildNodes();
        for (int i = 0; i < interceptors.getLength(); i++) {
            if ("class-name".equalsIgnoreCase(interceptors.item(i).getNodeName())) {
                String clazz = getTrimmedTextContent(interceptors.item(i));
                incomingInterceptorList.add(clazz);
            }
        }
    }
    NodeList incomingInterceptorNodes = e.getElementsByTagName("remoting-incoming-interceptors");
    if (incomingInterceptorNodes.getLength() > 0) {
        NodeList interceptors = incomingInterceptorNodes.item(0).getChildNodes();
        for (int i = 0; i < interceptors.getLength(); i++) {
            if ("class-name".equalsIgnoreCase(interceptors.item(i).getNodeName())) {
                String clazz = getTrimmedTextContent(interceptors.item(i));
                incomingInterceptorList.add(clazz);
            }
        }
    }
    config.setIncomingInterceptorClassNames(incomingInterceptorList);
    NodeList outgoingInterceptorNodes = e.getElementsByTagName("remoting-outgoing-interceptors");
    ArrayList<String> outgoingInterceptorList = new ArrayList<>();
    if (outgoingInterceptorNodes.getLength() > 0) {
        NodeList interceptors = outgoingInterceptorNodes.item(0).getChildNodes();
        for (int i = 0; i < interceptors.getLength(); i++) {
            if ("class-name".equalsIgnoreCase(interceptors.item(i).getNodeName())) {
                String clazz = interceptors.item(i).getTextContent();
                outgoingInterceptorList.add(clazz);
            }
        }
    }
    config.setOutgoingInterceptorClassNames(outgoingInterceptorList);
    NodeList connectorNodes = e.getElementsByTagName("connector");
    for (int i = 0; i < connectorNodes.getLength(); i++) {
        Element connectorNode = (Element) connectorNodes.item(i);
        TransportConfiguration connectorConfig = parseConnectorTransportConfiguration(connectorNode, config);
        if (connectorConfig.getName() == null) {
            ActiveMQServerLogger.LOGGER.connectorWithNoName();
            continue;
        }
        if (config.getConnectorConfigurations().containsKey(connectorConfig.getName())) {
            ActiveMQServerLogger.LOGGER.connectorAlreadyDeployed(connectorConfig.getName());
            continue;
        }
        config.getConnectorConfigurations().put(connectorConfig.getName(), connectorConfig);
    }
    NodeList acceptorNodes = e.getElementsByTagName("acceptor");
    for (int i = 0; i < acceptorNodes.getLength(); i++) {
        Element acceptorNode = (Element) acceptorNodes.item(i);
        TransportConfiguration acceptorConfig = parseAcceptorTransportConfiguration(acceptorNode, config);
        config.getAcceptorConfigurations().add(acceptorConfig);
    }
    NodeList bgNodes = e.getElementsByTagName("broadcast-group");
    for (int i = 0; i < bgNodes.getLength(); i++) {
        Element bgNode = (Element) bgNodes.item(i);
        parseBroadcastGroupConfiguration(bgNode, config);
    }
    NodeList dgNodes = e.getElementsByTagName("discovery-group");
    for (int i = 0; i < dgNodes.getLength(); i++) {
        Element dgNode = (Element) dgNodes.item(i);
        parseDiscoveryGroupConfiguration(dgNode, config);
    }
    NodeList brNodes = e.getElementsByTagName("bridge");
    for (int i = 0; i < brNodes.getLength(); i++) {
        Element mfNode = (Element) brNodes.item(i);
        parseBridgeConfiguration(mfNode, config);
    }
    NodeList gaNodes = e.getElementsByTagName("grouping-handler");
    for (int i = 0; i < gaNodes.getLength(); i++) {
        Element gaNode = (Element) gaNodes.item(i);
        parseGroupingHandlerConfiguration(gaNode, config);
    }
    NodeList ccNodes = e.getElementsByTagName("cluster-connection");
    for (int i = 0; i < ccNodes.getLength(); i++) {
        Element ccNode = (Element) ccNodes.item(i);
        parseClusterConnectionConfiguration(ccNode, config);
    }
    NodeList ccNodesURI = e.getElementsByTagName("cluster-connection-uri");
    for (int i = 0; i < ccNodesURI.getLength(); i++) {
        Element ccNode = (Element) ccNodesURI.item(i);
        parseClusterConnectionConfigurationURI(ccNode, config);
    }
    NodeList dvNodes = e.getElementsByTagName("divert");
    for (int i = 0; i < dvNodes.getLength(); i++) {
        Element dvNode = (Element) dvNodes.item(i);
        parseDivertConfiguration(dvNode, config);
    }
    // Persistence config
    config.setLargeMessagesDirectory(getString(e, "large-messages-directory", config.getLargeMessagesDirectory(), Validators.NOT_NULL_OR_EMPTY));
    config.setBindingsDirectory(getString(e, "bindings-directory", config.getBindingsDirectory(), Validators.NOT_NULL_OR_EMPTY));
    config.setCreateBindingsDir(getBoolean(e, "create-bindings-dir", config.isCreateBindingsDir()));
    config.setJournalDirectory(getString(e, "journal-directory", config.getJournalDirectory(), Validators.NOT_NULL_OR_EMPTY));
    config.setPageMaxConcurrentIO(getInteger(e, "page-max-concurrent-io", config.getPageMaxConcurrentIO(), Validators.MINUS_ONE_OR_GT_ZERO));
    config.setPagingDirectory(getString(e, "paging-directory", config.getPagingDirectory(), Validators.NOT_NULL_OR_EMPTY));
    config.setCreateJournalDir(getBoolean(e, "create-journal-dir", config.isCreateJournalDir()));
    String s = getString(e, "journal-type", config.getJournalType().toString(), Validators.JOURNAL_TYPE);
    config.setJournalType(JournalType.getType(s));
    if (config.getJournalType() == JournalType.ASYNCIO) {
        // https://jira.jboss.org/jira/browse/HORNETQ-295
        // We do the check here to see if AIO is supported so we can use the correct defaults and/or use
        // correct settings in xml
        // If we fall back later on these settings can be ignored
        boolean supportsAIO = AIOSequentialFileFactory.isSupported();
        if (!supportsAIO) {
            if (validateAIO) {
                ActiveMQServerLogger.LOGGER.AIONotFound();
            }
            config.setJournalType(JournalType.NIO);
        }
    }
    config.setJournalDatasync(getBoolean(e, "journal-datasync", config.isJournalDatasync()));
    config.setJournalSyncTransactional(getBoolean(e, "journal-sync-transactional", config.isJournalSyncTransactional()));
    config.setJournalSyncNonTransactional(getBoolean(e, "journal-sync-non-transactional", config.isJournalSyncNonTransactional()));
    config.setJournalFileSize(getTextBytesAsIntBytes(e, "journal-file-size", config.getJournalFileSize(), Validators.GT_ZERO));
    int journalBufferTimeout = getInteger(e, "journal-buffer-timeout", config.getJournalType() == JournalType.ASYNCIO ? ArtemisConstants.DEFAULT_JOURNAL_BUFFER_TIMEOUT_AIO : ArtemisConstants.DEFAULT_JOURNAL_BUFFER_TIMEOUT_NIO, Validators.GE_ZERO);
    int journalBufferSize = getTextBytesAsIntBytes(e, "journal-buffer-size", config.getJournalType() == JournalType.ASYNCIO ? ArtemisConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO : ArtemisConstants.DEFAULT_JOURNAL_BUFFER_SIZE_NIO, Validators.GT_ZERO);
    int journalMaxIO = getInteger(e, "journal-max-io", config.getJournalType() == JournalType.ASYNCIO ? ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio() : ActiveMQDefaultConfiguration.getDefaultJournalMaxIoNio(), Validators.GT_ZERO);
    if (config.getJournalType() == JournalType.ASYNCIO) {
        config.setJournalBufferTimeout_AIO(journalBufferTimeout);
        config.setJournalBufferSize_AIO(journalBufferSize);
        config.setJournalMaxIO_AIO(journalMaxIO);
    } else {
        config.setJournalBufferTimeout_NIO(journalBufferTimeout);
        config.setJournalBufferSize_NIO(journalBufferSize);
        config.setJournalMaxIO_NIO(journalMaxIO);
    }
    config.setJournalFileOpenTimeout(getInteger(e, "journal-file-open-timeout", ActiveMQDefaultConfiguration.getDefaultJournalFileOpenTimeout(), Validators.GT_ZERO));
    config.setJournalMinFiles(getInteger(e, "journal-min-files", config.getJournalMinFiles(), Validators.GT_ZERO));
    config.setJournalPoolFiles(getInteger(e, "journal-pool-files", config.getJournalPoolFiles(), Validators.MINUS_ONE_OR_GT_ZERO));
    config.setJournalCompactMinFiles(getInteger(e, "journal-compact-min-files", config.getJournalCompactMinFiles(), Validators.GE_ZERO));
    config.setJournalCompactPercentage(getInteger(e, "journal-compact-percentage", config.getJournalCompactPercentage(), Validators.PERCENTAGE));
    config.setLogJournalWriteRate(getBoolean(e, "log-journal-write-rate", ActiveMQDefaultConfiguration.isDefaultJournalLogWriteRate()));
    if (e.hasAttribute("wild-card-routing-enabled")) {
        config.setWildcardRoutingEnabled(getBoolean(e, "wild-card-routing-enabled", config.isWildcardRoutingEnabled()));
    }
    config.setMessageCounterEnabled(getBoolean(e, "message-counter-enabled", config.isMessageCounterEnabled()));
    config.setMessageCounterSamplePeriod(getLong(e, "message-counter-sample-period", config.getMessageCounterSamplePeriod(), Validators.GT_ZERO));
    config.setMessageCounterMaxDayHistory(getInteger(e, "message-counter-max-day-history", config.getMessageCounterMaxDayHistory(), Validators.GT_ZERO));
    // in milliseconds
    config.setServerDumpInterval(getLong(e, "server-dump-interval", config.getServerDumpInterval(), Validators.MINUS_ONE_OR_GT_ZERO));
    config.setMemoryWarningThreshold(getInteger(e, "memory-warning-threshold", config.getMemoryWarningThreshold(), Validators.PERCENTAGE));
    config.setMemoryMeasureInterval(getLong(e, "memory-measure-interval", config.getMemoryMeasureInterval(), Validators.MINUS_ONE_OR_GT_ZERO));
    config.setNetworkCheckList(getString(e, "network-check-list", config.getNetworkCheckList(), Validators.NO_CHECK));
    config.setNetworkCheckURLList(getString(e, "network-check-URL-list", config.getNetworkCheckURLList(), Validators.NO_CHECK));
    config.setNetworkCheckPeriod(getLong(e, "network-check-period", config.getNetworkCheckPeriod(), Validators.GT_ZERO));
    config.setNetworkCheckTimeout(getInteger(e, "network-check-timeout", config.getNetworkCheckTimeout(), Validators.GT_ZERO));
    config.setNetworCheckNIC(getString(e, "network-check-NIC", config.getNetworkCheckNIC(), Validators.NO_CHECK));
    config.setNetworkCheckPing6Command(getString(e, "network-check-ping6-command", config.getNetworkCheckPing6Command(), Validators.NO_CHECK));
    config.setNetworkCheckPingCommand(getString(e, "network-check-ping-command", config.getNetworkCheckPingCommand(), Validators.NO_CHECK));
    config.setCriticalAnalyzer(getBoolean(e, "critical-analyzer", config.isCriticalAnalyzer()));
    config.setCriticalAnalyzerTimeout(getLong(e, "critical-analyzer-timeout", config.getCriticalAnalyzerTimeout(), Validators.GE_ZERO));
    config.setCriticalAnalyzerCheckPeriod(getLong(e, "critical-analyzer-check-period", config.getCriticalAnalyzerCheckPeriod(), Validators.GE_ZERO));
    config.setCriticalAnalyzerPolicy(CriticalAnalyzerPolicy.valueOf(getString(e, "critical-analyzer-policy", config.getCriticalAnalyzerPolicy().name(), Validators.NOT_NULL_OR_EMPTY)));
    parseAddressSettings(e, config);
    parseResourceLimits(e, config);
    parseQueues(e, config);
    parseAddresses(e, config);
    parseSecurity(e, config);
    parseBrokerPlugins(e, config);
    NodeList connectorServiceConfigs = e.getElementsByTagName("connector-service");
    ArrayList<ConnectorServiceConfiguration> configs = new ArrayList<>();
    for (int i = 0; i < connectorServiceConfigs.getLength(); i++) {
        Element node = (Element) connectorServiceConfigs.item(i);
        configs.add((parseConnectorService(node)));
    }
    config.setConnectorServiceConfigurations(configs);
    NodeList wildCardConfiguration = e.getElementsByTagName("wildcard-addresses");
    if (wildCardConfiguration.getLength() > 0) {
        parseWildcardConfiguration((Element) wildCardConfiguration.item(0), config);
    }
}
Also used : NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) LiveOnlyPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration) ConnectorServiceConfiguration(org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration)

Example 2 with ConnectorServiceConfiguration

use of org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration in project activemq-artemis by apache.

the class FileConfigurationParser method parseConnectorService.

private ConnectorServiceConfiguration parseConnectorService(final Element e) {
    Node nameNode = e.getAttributes().getNamedItem("name");
    String name = nameNode != null ? nameNode.getNodeValue() : null;
    String clazz = getString(e, "factory-class", null, Validators.NOT_NULL_OR_EMPTY);
    Map<String, Object> params = new HashMap<>();
    NodeList paramsNodes = e.getElementsByTagName("param");
    for (int i = 0; i < paramsNodes.getLength(); i++) {
        Node paramNode = paramsNodes.item(i);
        NamedNodeMap attributes = paramNode.getAttributes();
        Node nkey = attributes.getNamedItem("key");
        String key = nkey.getTextContent();
        Node nValue = attributes.getNamedItem("value");
        params.put(key, nValue.getTextContent());
    }
    return new ConnectorServiceConfiguration().setFactoryClassName(clazz).setParams(params).setName(name);
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) HashMap(java.util.HashMap) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ConnectorServiceConfiguration(org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration)

Example 3 with ConnectorServiceConfiguration

use of org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration in project activemq-artemis by apache.

the class ActiveMQServerControlImpl method createConnectorService.

@Override
public void createConnectorService(final String name, final String factoryClass, final Map<String, Object> parameters) throws Exception {
    checkStarted();
    clearIO();
    try {
        final ConnectorServiceConfiguration config = new ConnectorServiceConfiguration().setName(name).setFactoryClassName(factoryClass).setParams(parameters);
        ConnectorServiceFactory factory = server.getServiceRegistry().getConnectorService(config);
        server.getConnectorsService().createService(config, factory);
    } finally {
        blockOnIO();
    }
}
Also used : ConnectorServiceFactory(org.apache.activemq.artemis.core.server.ConnectorServiceFactory) ConnectorServiceConfiguration(org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration)

Example 4 with ConnectorServiceConfiguration

use of org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration in project activemq-artemis by apache.

the class ConnectorsServiceTest method testConnectorsServiceUsesInjectedConnectorServiceFactory.

/**
 * Test that the connectors added via the service registry are added to the connectorsService,
 *
 * @throws Exception
 */
@Test
public void testConnectorsServiceUsesInjectedConnectorServiceFactory() throws Exception {
    ConnectorServiceConfiguration connectorServiceConfiguration = new ConnectorServiceConfiguration().setFactoryClassName(null).setParams(new HashMap<String, Object>()).setName("myfact");
    // Creates a fake connector service factory that returns the fake connector service object
    ConnectorService connectorService = new FakeConnectorService();
    FakeConnectorServiceFactory connectorServiceFactory = new FakeConnectorServiceFactory();
    serviceRegistry.addConnectorService(connectorServiceFactory, connectorServiceConfiguration);
    ConnectorsService connectorsService = new ConnectorsService(configuration, null, null, null, serviceRegistry);
    connectorsService.start();
    assertTrue(connectorsService.getConnectors().size() == 1);
    assertTrue(connectorsService.getConnectors().values().contains(connectorServiceFactory.getConnectorService()));
}
Also used : FakeConnectorServiceFactory(org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorServiceFactory) HashMap(java.util.HashMap) FakeConnectorService(org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorService) ConnectorServiceConfiguration(org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration) ConnectorsService(org.apache.activemq.artemis.core.server.impl.ConnectorsService) FakeConnectorService(org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorService) ConnectorService(org.apache.activemq.artemis.core.server.ConnectorService) Test(org.junit.Test)

Example 5 with ConnectorServiceConfiguration

use of org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration in project activemq-artemis by apache.

the class ConnectorsServiceTest method testConnectorsServiceUsesConfiguredConnectorServices.

/**
 * Test that the connectors added via the config are added to the connectors service.
 *
 * @throws Exception
 */
@Test
public void testConnectorsServiceUsesConfiguredConnectorServices() throws Exception {
    ConnectorServiceConfiguration connectorServiceConfiguration = new ConnectorServiceConfiguration().setFactoryClassName(FakeConnectorServiceFactory.class.getCanonicalName()).setParams(new HashMap<String, Object>()).setName("myfact");
    List<ConnectorServiceConfiguration> connectorServiceConfigurations = new ArrayList<>();
    connectorServiceConfigurations.add(connectorServiceConfiguration);
    configuration.setConnectorServiceConfigurations(connectorServiceConfigurations);
    ConnectorsService connectorsService = new ConnectorsService(configuration, null, null, null, serviceRegistry);
    connectorsService.start();
    assertTrue(connectorsService.getConnectors().size() == 1);
}
Also used : FakeConnectorServiceFactory(org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorServiceFactory) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ConnectorServiceConfiguration(org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration) ConnectorsService(org.apache.activemq.artemis.core.server.impl.ConnectorsService) Test(org.junit.Test)

Aggregations

ConnectorServiceConfiguration (org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration)8 HashMap (java.util.HashMap)5 ConnectorsService (org.apache.activemq.artemis.core.server.impl.ConnectorsService)3 FakeConnectorServiceFactory (org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorServiceFactory)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)2 ConnectorServiceFactory (org.apache.activemq.artemis.core.server.ConnectorServiceFactory)2 NodeList (org.w3c.dom.NodeList)2 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)1 LiveOnlyPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration)1 ConnectorService (org.apache.activemq.artemis.core.server.ConnectorService)1 FakeConnectorService (org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorService)1 Element (org.w3c.dom.Element)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1 Node (org.w3c.dom.Node)1