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();
}
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;
}
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;
}
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);
}
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);
}
Aggregations