Search in sources :

Example 36 with DiscoveryGroupConfiguration

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

the class ResourceAdapterTest method testResourceAdapterSetupOverrideDiscovery.

@Test
public void testResourceAdapterSetupOverrideDiscovery() throws Exception {
    ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter();
    qResourceAdapter.setDiscoveryAddress("231.7.7.7");
    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);
    spec.setSetupAttempts(0);
    spec.setDiscoveryAddress("231.6.6.6");
    spec.setDiscoveryPort(1234);
    spec.setDiscoveryInitialWaitTimeout(1L);
    spec.setDiscoveryRefreshTimeout(1L);
    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 37 with DiscoveryGroupConfiguration

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

the class ClusterTestBase method setupLiveServerWithDiscovery.

protected void setupLiveServerWithDiscovery(final int node, 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(200).setConnectorInfos(connectorPairs).setEndpointFactory(endpoint);
    DiscoveryGroupConfiguration dcConfig = new DiscoveryGroupConfiguration().setName("dg1").setRefreshTimeout(1000).setDiscoveryInitialWaitTimeout(1000).setBroadcastEndpointFactory(endpoint);
    Configuration configuration = createBasicConfig(node).setJournalMaxIO_AIO(1000).clearAcceptorConfigurations().addAcceptorConfiguration(createTransportConfiguration(netty, true, params)).addConnectorConfiguration(connector.getName(), connector).addBroadcastGroupConfiguration(bcConfig).addDiscoveryGroupConfiguration(dcConfig.getName(), dcConfig).setHAPolicyConfiguration(sharedStorage ? new SharedStoreMasterPolicyConfiguration() : new ReplicatedPolicyConfiguration());
    ActiveMQServer server;
    if (fileStorage) {
        if (sharedStorage) {
            server = createInVMFailoverServer(true, configuration, nodeManagers[node], node);
        } else {
            server = addServer(ActiveMQServers.newActiveMQServer(configuration));
            server.setIdentity("Server " + node);
        }
    } else {
        if (sharedStorage) {
            server = createInVMFailoverServer(false, configuration, nodeManagers[node], node);
        } else {
            server = addServer(ActiveMQServers.newActiveMQServer(configuration, false));
            server.setIdentity("Server " + node);
        }
    }
    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) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) 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) 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 38 with DiscoveryGroupConfiguration

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

the class JMSServerManagerImpl method internalCreateCFPOJO.

/**
 * @param cfConfig
 * @return
 * @throws ActiveMQException
 */
protected ActiveMQConnectionFactory internalCreateCFPOJO(final ConnectionFactoryConfiguration cfConfig) throws ActiveMQException {
    ActiveMQConnectionFactory cf;
    if (cfConfig.getDiscoveryGroupName() != null) {
        DiscoveryGroupConfiguration groupConfig = server.getConfiguration().getDiscoveryGroupConfigurations().get(cfConfig.getDiscoveryGroupName());
        if (groupConfig == null) {
            throw ActiveMQJMSServerBundle.BUNDLE.discoveryGroupDoesntExist(cfConfig.getDiscoveryGroupName());
        }
        if (cfConfig.isHA()) {
            cf = ActiveMQJMSClient.createConnectionFactoryWithHA(groupConfig, cfConfig.getFactoryType());
        } else {
            cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(groupConfig, cfConfig.getFactoryType());
        }
    } else {
        if (cfConfig.getConnectorNames() == null || cfConfig.getConnectorNames().size() == 0) {
            throw ActiveMQJMSServerBundle.BUNDLE.noConnectorNameOnCF();
        }
        TransportConfiguration[] configs = new TransportConfiguration[cfConfig.getConnectorNames().size()];
        int count = 0;
        for (String name : cfConfig.getConnectorNames()) {
            TransportConfiguration connector = server.getConfiguration().getConnectorConfigurations().get(name);
            if (connector == null) {
                throw ActiveMQJMSServerBundle.BUNDLE.noConnectorNameConfiguredOnCF(name);
            }
            correctInvalidNettyConnectorHost(connector);
            configs[count++] = connector;
        }
        if (cfConfig.isHA()) {
            cf = ActiveMQJMSClient.createConnectionFactoryWithHA(cfConfig.getFactoryType(), configs);
        } else {
            cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(cfConfig.getFactoryType(), configs);
        }
    }
    cf.setClientID(cfConfig.getClientID());
    cf.setClientFailureCheckPeriod(cfConfig.getClientFailureCheckPeriod());
    cf.setConnectionTTL(cfConfig.getConnectionTTL());
    cf.setCallTimeout(cfConfig.getCallTimeout());
    cf.setCallFailoverTimeout(cfConfig.getCallFailoverTimeout());
    cf.setCacheLargeMessagesClient(cfConfig.isCacheLargeMessagesClient());
    cf.setMinLargeMessageSize(cfConfig.getMinLargeMessageSize());
    cf.setConsumerWindowSize(cfConfig.getConsumerWindowSize());
    cf.setConsumerMaxRate(cfConfig.getConsumerMaxRate());
    cf.setConfirmationWindowSize(cfConfig.getConfirmationWindowSize());
    cf.setProducerWindowSize(cfConfig.getProducerWindowSize());
    cf.setProducerMaxRate(cfConfig.getProducerMaxRate());
    cf.setBlockOnAcknowledge(cfConfig.isBlockOnAcknowledge());
    cf.setBlockOnDurableSend(cfConfig.isBlockOnDurableSend());
    cf.setBlockOnNonDurableSend(cfConfig.isBlockOnNonDurableSend());
    cf.setAutoGroup(cfConfig.isAutoGroup());
    cf.setPreAcknowledge(cfConfig.isPreAcknowledge());
    cf.setConnectionLoadBalancingPolicyClassName(cfConfig.getLoadBalancingPolicyClassName());
    cf.setTransactionBatchSize(cfConfig.getTransactionBatchSize());
    cf.setDupsOKBatchSize(cfConfig.getDupsOKBatchSize());
    cf.setUseGlobalPools(cfConfig.isUseGlobalPools());
    cf.setScheduledThreadPoolMaxSize(cfConfig.getScheduledThreadPoolMaxSize());
    cf.setThreadPoolMaxSize(cfConfig.getThreadPoolMaxSize());
    cf.setRetryInterval(cfConfig.getRetryInterval());
    cf.setRetryIntervalMultiplier(cfConfig.getRetryIntervalMultiplier());
    cf.setMaxRetryInterval(cfConfig.getMaxRetryInterval());
    cf.setReconnectAttempts(cfConfig.getReconnectAttempts());
    cf.setFailoverOnInitialConnection(cfConfig.isFailoverOnInitialConnection());
    cf.setCompressLargeMessage(cfConfig.isCompressLargeMessages());
    cf.setGroupID(cfConfig.getGroupID());
    cf.setProtocolManagerFactoryStr(cfConfig.getProtocolManagerFactoryStr());
    cf.setDeserializationBlackList(cfConfig.getDeserializationBlackList());
    cf.setDeserializationWhiteList(cfConfig.getDeserializationWhiteList());
    cf.setInitialMessagePacketSize(cfConfig.getInitialMessagePacketSize());
    return cf;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 39 with DiscoveryGroupConfiguration

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

the class JGroupsSchema method internalNewURI.

@Override
protected URI internalNewURI(ActiveMQConnectionFactory bean) throws Exception {
    DiscoveryGroupConfiguration dgc = bean.getDiscoveryGroupConfiguration();
    BroadcastEndpointFactory endpoint = dgc.getBroadcastEndpointFactory();
    String auth;
    if (endpoint instanceof JGroupsFileBroadcastEndpointFactory) {
        auth = ((JGroupsFileBroadcastEndpointFactory) endpoint).getChannelName();
    } else if (endpoint instanceof JGroupsPropertiesBroadcastEndpointFactory) {
        auth = ((JGroupsPropertiesBroadcastEndpointFactory) endpoint).getChannelName();
    } else {
        throw new NotSerializableException(endpoint + "not serializable");
    }
    String query = BeanSupport.getData(null, bean, dgc, endpoint);
    dgc.setBroadcastEndpointFactory(endpoint);
    return new URI(SchemaConstants.JGROUPS, null, auth, -1, null, query, null);
}
Also used : NotSerializableException(java.io.NotSerializableException) JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) JGroupsFileBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) URI(java.net.URI) JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) JGroupsFileBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory) BroadcastEndpointFactory(org.apache.activemq.artemis.api.core.BroadcastEndpointFactory)

Example 40 with DiscoveryGroupConfiguration

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

the class ConnectionFactoryURITest method testJGroupsPropertiesURI.

@Test
public void testJGroupsPropertiesURI() throws Exception {
    DiscoveryGroupConfiguration discoveryGroupConfiguration = new DiscoveryGroupConfiguration();
    JGroupsPropertiesBroadcastEndpointFactory endpointFactory = new JGroupsPropertiesBroadcastEndpointFactory().setChannelName("channel-name").setProperties("param=val,param2-val2");
    discoveryGroupConfiguration.setName("foo").setRefreshTimeout(12345).setDiscoveryInitialWaitTimeout(5678).setBroadcastEndpointFactory(endpointFactory);
    ActiveMQConnectionFactory connectionFactoryWithHA = ActiveMQJMSClient.createConnectionFactoryWithHA(discoveryGroupConfiguration, JMSFactoryType.CF);
    URI tcp = parser.createSchema("jgroups", connectionFactoryWithHA);
    ActiveMQConnectionFactory factory = parser.newObject(tcp, null);
    DiscoveryGroupConfiguration dgc = factory.getDiscoveryGroupConfiguration();
    Assert.assertNotNull(dgc);
    BroadcastEndpointFactory broadcastEndpointFactory = dgc.getBroadcastEndpointFactory();
    Assert.assertNotNull(broadcastEndpointFactory);
    Assert.assertTrue(broadcastEndpointFactory instanceof JGroupsPropertiesBroadcastEndpointFactory);
    Assert.assertEquals(dgc.getName(), "foo");
    Assert.assertEquals(dgc.getDiscoveryInitialWaitTimeout(), 5678);
    Assert.assertEquals(dgc.getRefreshTimeout(), 12345);
    JGroupsPropertiesBroadcastEndpointFactory propertiesBroadcastEndpointFactory = (JGroupsPropertiesBroadcastEndpointFactory) broadcastEndpointFactory;
    Assert.assertEquals(propertiesBroadcastEndpointFactory.getProperties(), "param=val,param2-val2");
    Assert.assertEquals(propertiesBroadcastEndpointFactory.getChannelName(), "channel-name");
    BeanUtilsBean bean = new BeanUtilsBean();
    checkEquals(bean, connectionFactoryWithHA, factory);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) BeanUtilsBean(org.apache.commons.beanutils.BeanUtilsBean) JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) URI(java.net.URI) JGroupsFileBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory) JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) BroadcastEndpointFactory(org.apache.activemq.artemis.api.core.BroadcastEndpointFactory) Test(org.junit.Test)

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