use of org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory in project activemq-artemis by apache.
the class ConnectionFactorySerializationTest method createDiscoveryFactoryJGroupsProperties.
private void createDiscoveryFactoryJGroupsProperties() throws Exception {
// Deploy a connection factory with discovery
List<String> bindings = new ArrayList<>();
bindings.add("MyConnectionFactory");
JGroupsPropertiesBroadcastEndpointFactory config = new JGroupsPropertiesBroadcastEndpointFactory().setChannelName("myChannel").setProperties("param=1,param2=2");
DiscoveryGroupConfiguration dcConfig = new DiscoveryGroupConfiguration().setName("dg1").setRefreshTimeout(5000).setDiscoveryInitialWaitTimeout(5000).setBroadcastEndpointFactory(config);
jmsServer.getActiveMQServer().getConfiguration().getDiscoveryGroupConfigurations().put(dcConfig.getName(), dcConfig);
jmsServer.createConnectionFactory("MyConnectionFactory", false, JMSFactoryType.CF, dcConfig.getName(), "/MyConnectionFactory");
}
use of org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory 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.JGroupsPropertiesBroadcastEndpointFactory 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);
}
use of org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory in project activemq-artemis by apache.
the class ConnectionFactorySerializationTest method testConnectionFactoryJgroupsProperties.
@Test
public void testConnectionFactoryJgroupsProperties() throws Exception {
createDiscoveryFactoryJGroupsProperties();
cf = (ActiveMQConnectionFactory) namingContext.lookup("/MyConnectionFactory");
// apparently looking up the connection factory with the org.apache.activemq.artemis.jms.tests.tools.container.InVMInitialContextFactory
// is not enough to actually serialize it so we serialize it manually
byte[] x = serialize(cf);
ActiveMQConnectionFactory y = deserialize(x, ActiveMQConnectionFactory.class);
checkEquals(cf, y);
DiscoveryGroupConfiguration dgc = y.getDiscoveryGroupConfiguration();
Assert.assertEquals(dgc.getName(), "dg1");
Assert.assertEquals(dgc.getDiscoveryInitialWaitTimeout(), 5000);
Assert.assertEquals(dgc.getRefreshTimeout(), 5000);
Assert.assertTrue(dgc.getBroadcastEndpointFactory() instanceof JGroupsPropertiesBroadcastEndpointFactory);
JGroupsPropertiesBroadcastEndpointFactory befc = (JGroupsPropertiesBroadcastEndpointFactory) dgc.getBroadcastEndpointFactory();
Assert.assertEquals("myChannel", befc.getChannelName());
Assert.assertEquals("param=1,param2=2", befc.getProperties());
}
Aggregations