Search in sources :

Example 1 with ConnectorService

use of org.apache.activemq.artemis.core.server.ConnectorService 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 2 with ConnectorService

use of org.apache.activemq.artemis.core.server.ConnectorService in project activemq-artemis by apache.

the class ConnectorsService method destroyService.

public synchronized void destroyService(String name) throws Exception {
    if (!connectors.containsKey(name)) {
        throw ActiveMQExceptionType.GENERIC_EXCEPTION.createException("Connector service " + name + " does not exist");
    }
    ConnectorService connectorService = connectors.get(name);
    connectorService.stop();
    connectors.remove(name);
}
Also used : ConnectorService(org.apache.activemq.artemis.core.server.ConnectorService)

Example 3 with ConnectorService

use of org.apache.activemq.artemis.core.server.ConnectorService in project activemq-artemis by apache.

the class ConnectorsService method createService.

public synchronized void createService(ConnectorServiceConfiguration info, ConnectorServiceFactory factory) throws Exception {
    if (connectors.containsKey(info.getConnectorName())) {
        throw ActiveMQExceptionType.GENERIC_EXCEPTION.createException("Connector service " + info.getConnectorName() + " already created");
    }
    if (info.getParams() != null) {
        Set<String> invalid = ConfigurationHelper.checkKeys(factory.getAllowableProperties(), info.getParams().keySet());
        if (!invalid.isEmpty()) {
            throw ActiveMQExceptionType.GENERIC_EXCEPTION.createException("Invalid connector keys for connector service " + info.getConnectorName() + ": " + ConfigurationHelper.stringSetToCommaListString(invalid));
        }
    }
    Set<String> invalid = ConfigurationHelper.checkKeysExist(factory.getRequiredProperties(), info.getParams().keySet());
    if (!invalid.isEmpty()) {
        throw ActiveMQExceptionType.GENERIC_EXCEPTION.createException("Missing connector keys for connector service " + info.getConnectorName() + ": " + ConfigurationHelper.stringSetToCommaListString(invalid));
    }
    ConnectorService connectorService = factory.createConnectorService(info.getConnectorName(), info.getParams(), storageManager, postOffice, scheduledPool);
    connectorService.start();
    connectors.put(info.getConnectorName(), connectorService);
}
Also used : ConnectorService(org.apache.activemq.artemis.core.server.ConnectorService)

Aggregations

ConnectorService (org.apache.activemq.artemis.core.server.ConnectorService)3 HashMap (java.util.HashMap)1 ConnectorServiceConfiguration (org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration)1 ConnectorsService (org.apache.activemq.artemis.core.server.impl.ConnectorsService)1 FakeConnectorService (org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorService)1 FakeConnectorServiceFactory (org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorServiceFactory)1 Test (org.junit.Test)1