Search in sources :

Example 11 with DiscoveryGroupConfiguration

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

the class JGroupsSchema method internalNewObject.

@Override
public ActiveMQConnectionFactory internalNewObject(URI uri, Map<String, String> query, String name) throws Exception {
    JMSConnectionOptions options = newConectionOptions(uri, query);
    DiscoveryGroupConfiguration dcConfig = JGroupsServerLocatorSchema.getDiscoveryGroupConfiguration(uri, query, name);
    ActiveMQConnectionFactory factory;
    if (options.isHa()) {
        factory = ActiveMQJMSClient.createConnectionFactoryWithHA(dcConfig, options.getFactoryTypeEnum());
    } else {
        factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(dcConfig, options.getFactoryTypeEnum());
    }
    return BeanSupport.setData(uri, factory, query);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)

Example 12 with DiscoveryGroupConfiguration

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

the class UDPSchema method internalNewObject.

@Override
public ActiveMQConnectionFactory internalNewObject(URI uri, Map<String, String> query, String name) throws Exception {
    JMSConnectionOptions options = newConectionOptions(uri, query);
    DiscoveryGroupConfiguration dgc = UDPServerLocatorSchema.getDiscoveryGroupConfiguration(uri, query, getHost(uri), getPort(uri), name);
    ActiveMQConnectionFactory factory;
    if (options.isHa()) {
        factory = ActiveMQJMSClient.createConnectionFactoryWithHA(dgc, options.getFactoryTypeEnum());
    } else {
        factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(dgc, options.getFactoryTypeEnum());
    }
    return BeanSupport.setData(uri, factory, query);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)

Example 13 with DiscoveryGroupConfiguration

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

the class UDPSchema method internalNewURI.

@Override
protected URI internalNewURI(ActiveMQConnectionFactory bean) throws Exception {
    DiscoveryGroupConfiguration dgc = bean.getDiscoveryGroupConfiguration();
    UDPBroadcastEndpointFactory endpoint = (UDPBroadcastEndpointFactory) dgc.getBroadcastEndpointFactory();
    String query = BeanSupport.getData(UDPServerLocatorSchema.IGNORED, bean, dgc, endpoint);
    dgc.setBroadcastEndpointFactory(endpoint);
    return new URI(SchemaConstants.UDP, null, endpoint.getGroupAddress(), endpoint.getGroupPort(), null, query, null);
}
Also used : DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) URI(java.net.URI)

Example 14 with DiscoveryGroupConfiguration

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

the class ResourceAdapterTest method testCreateConnectionFactoryOverrideDiscovery.

@Test
public void testCreateConnectionFactoryOverrideDiscovery() throws Exception {
    ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
    ra.setConnectorClassName(InVMConnectorFactory.class.getName());
    ConnectionFactoryProperties connectionFactoryProperties = new ConnectionFactoryProperties();
    connectionFactoryProperties.setDiscoveryAddress("myhost");
    connectionFactoryProperties.setDiscoveryPort(5678);
    connectionFactoryProperties.setDiscoveryLocalBindAddress("newAddress");
    ActiveMQConnectionFactory factory = ra.getConnectionFactory(connectionFactoryProperties);
    ActiveMQConnectionFactory defaultFactory = ra.getDefaultActiveMQConnectionFactory();
    Assert.assertNotSame(factory, defaultFactory);
    DiscoveryGroupConfiguration dc = factory.getServerLocator().getDiscoveryGroupConfiguration();
    UDPBroadcastEndpointFactory udpDg = (UDPBroadcastEndpointFactory) dc.getBroadcastEndpointFactory();
    Assert.assertEquals(udpDg.getLocalBindAddress(), "newAddress");
    Assert.assertEquals(udpDg.getGroupAddress(), "myhost");
    Assert.assertEquals(udpDg.getGroupPort(), 5678);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ConnectionFactoryProperties(org.apache.activemq.artemis.ra.ConnectionFactoryProperties) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) InVMConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) Test(org.junit.Test)

Example 15 with DiscoveryGroupConfiguration

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

the class SharedNothingLiveActivation method getLocator.

private ServerLocatorInternal getLocator(ClusterConnectionConfiguration config) throws ActiveMQException {
    ServerLocatorInternal locator;
    if (config.getDiscoveryGroupName() != null) {
        DiscoveryGroupConfiguration dg = activeMQServer.getConfiguration().getDiscoveryGroupConfigurations().get(config.getDiscoveryGroupName());
        if (dg == null) {
            throw ActiveMQMessageBundle.BUNDLE.noDiscoveryGroupFound(dg);
        }
        locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithHA(dg);
    } else {
        TransportConfiguration[] tcConfigs = config.getStaticConnectors() != null ? connectorNameListToArray(config.getStaticConnectors()) : null;
        locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithHA(tcConfigs);
    }
    return locator;
}
Also used : TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) ServerLocatorInternal(org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal)

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