use of org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory in project activemq-artemis by apache.
the class JGroupsServerLocatorSchema method internalNewURI.
@Override
protected URI internalNewURI(ServerLocator 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.JGroupsPropertiesBroadcastEndpointFactory in project activemq-artemis by apache.
the class JGroupsServerLocatorSchema method getDiscoveryGroupConfiguration.
public static DiscoveryGroupConfiguration getDiscoveryGroupConfiguration(URI uri, Map<String, String> query, String name) throws Exception {
BroadcastEndpointFactory endpointFactory;
if (query.containsKey("file")) {
endpointFactory = new JGroupsFileBroadcastEndpointFactory().setChannelName(uri.getAuthority());
} else {
endpointFactory = new JGroupsPropertiesBroadcastEndpointFactory().setChannelName(uri.getAuthority());
}
BeanSupport.setData(uri, endpointFactory, query);
DiscoveryGroupConfiguration dcConfig = new DiscoveryGroupConfiguration().setName(name).setBroadcastEndpointFactory(endpointFactory);
BeanSupport.setData(uri, dcConfig, query);
return dcConfig;
}
use of org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory in project activemq-artemis by apache.
the class ConnectionFactoryURITest method testJGroupsKeyValue.
@Test
public void testJGroupsKeyValue() throws Exception {
ActiveMQConnectionFactory factory = parser.newObject(new URI("jgroups://channel-name?properties=param=value;param2=value2&test=33"), null);
Assert.assertTrue(ActiveMQJMSConnectionFactory.class.getName().equals(factory.getClass().getName()));
JGroupsPropertiesBroadcastEndpointFactory broadcastEndpointFactory = (JGroupsPropertiesBroadcastEndpointFactory) factory.getDiscoveryGroupConfiguration().getBroadcastEndpointFactory();
Assert.assertEquals(broadcastEndpointFactory.getProperties(), "param=value;param2=value2");
Assert.assertEquals(broadcastEndpointFactory.getChannelName(), "channel-name");
}
use of org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory in project activemq-artemis by apache.
the class SimpleJNDIClientTest method testRemoteCFWithJgroupsWithTransportConfigNullProps.
@Test
public void testRemoteCFWithJgroupsWithTransportConfigNullProps() throws Exception {
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName());
props.put("connectionFactory.ConnectionFactory", "jgroups://testChannelName?" + ActiveMQInitialContextFactory.REFRESH_TIMEOUT + "=5000&" + ActiveMQInitialContextFactory.DISCOVERY_INITIAL_WAIT_TIMEOUT + "=6000");
Context ctx = new InitialContext(props);
ActiveMQConnectionFactory cf = (ActiveMQConnectionFactory) ctx.lookup("ConnectionFactory");
DiscoveryGroupConfiguration discoveryGroupConfiguration = cf.getDiscoveryGroupConfiguration();
Assert.assertEquals(5000, discoveryGroupConfiguration.getRefreshTimeout());
Assert.assertEquals(6000, discoveryGroupConfiguration.getDiscoveryInitialWaitTimeout());
BroadcastEndpointFactory broadcastEndpointFactory = cf.getDiscoveryGroupConfiguration().getBroadcastEndpointFactory();
Assert.assertTrue(broadcastEndpointFactory instanceof JGroupsPropertiesBroadcastEndpointFactory);
JGroupsPropertiesBroadcastEndpointFactory endpointFactory = (JGroupsPropertiesBroadcastEndpointFactory) broadcastEndpointFactory;
Assert.assertEquals(endpointFactory.getProperties(), null);
Assert.assertEquals(endpointFactory.getChannelName(), "testChannelName");
}
use of org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory in project activemq-artemis by apache.
the class SimpleJNDIClientTest method testRemoteCFWithJgroupsWithTransportConfigProps.
@Test
public void testRemoteCFWithJgroupsWithTransportConfigProps() throws Exception {
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName());
props.put("connectionFactory.ConnectionFactory", "jgroups://testChannelName?properties=param=value&" + ActiveMQInitialContextFactory.REFRESH_TIMEOUT + "=5000&" + ActiveMQInitialContextFactory.DISCOVERY_INITIAL_WAIT_TIMEOUT + "=6000");
Context ctx = new InitialContext(props);
ActiveMQConnectionFactory cf = (ActiveMQConnectionFactory) ctx.lookup("ConnectionFactory");
DiscoveryGroupConfiguration discoveryGroupConfiguration = cf.getDiscoveryGroupConfiguration();
Assert.assertEquals(5000, discoveryGroupConfiguration.getRefreshTimeout());
Assert.assertEquals(6000, discoveryGroupConfiguration.getDiscoveryInitialWaitTimeout());
BroadcastEndpointFactory broadcastEndpointFactory = cf.getDiscoveryGroupConfiguration().getBroadcastEndpointFactory();
Assert.assertTrue(broadcastEndpointFactory instanceof JGroupsPropertiesBroadcastEndpointFactory);
JGroupsPropertiesBroadcastEndpointFactory endpointFactory = (JGroupsPropertiesBroadcastEndpointFactory) broadcastEndpointFactory;
Assert.assertEquals(endpointFactory.getProperties(), "param=value");
Assert.assertEquals(endpointFactory.getChannelName(), "testChannelName");
}
Aggregations