use of org.jgroups.conf.PlainConfigurator in project activemq-artemis by apache.
the class JGroupsBroadcastTest method testRefCount.
@Test
public void testRefCount() throws Exception {
JChannel channel = null;
JChannel newChannel = null;
try {
PlainConfigurator configurator = new PlainConfigurator(jgroupsConfigString);
channel = new JChannel(configurator);
String channelName1 = "channel1";
BroadcastEndpointFactory jgroupsBroadcastCfg1 = new ChannelBroadcastEndpointFactory(channel, channelName1);
BroadcastEndpoint channelEndpoint1 = jgroupsBroadcastCfg1.createBroadcastEndpoint();
BroadcastEndpoint channelEndpoint2 = jgroupsBroadcastCfg1.createBroadcastEndpoint();
BroadcastEndpoint channelEndpoint3 = jgroupsBroadcastCfg1.createBroadcastEndpoint();
channelEndpoint1.close(true);
Assert.assertTrue(channel.isOpen());
channelEndpoint2.close(true);
Assert.assertTrue(channel.isOpen());
channelEndpoint3.close(true);
Assert.assertTrue(channel.isOpen());
channel.close();
// channel wrapper is recreated
try {
channelEndpoint2.openClient();
Assert.fail("this should be closed");
} catch (Exception e) {
}
newChannel = new JChannel(configurator);
jgroupsBroadcastCfg1 = new ChannelBroadcastEndpointFactory(newChannel, channelName1);
channelEndpoint1 = jgroupsBroadcastCfg1.createBroadcastEndpoint();
channelEndpoint1.openClient();
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
try {
channel.close();
} catch (Throwable ignored) {
}
try {
newChannel.close();
} catch (Throwable ignored) {
}
}
}
use of org.jgroups.conf.PlainConfigurator in project activemq-artemis by apache.
the class ConnectionFactoryWithJGroupsSerializationTest method setUp.
@Override
@Before
public void setUp() throws Exception {
try {
super.setUp();
PlainConfigurator configurator = new PlainConfigurator(jgroupsConfigString);
channel = new JChannel(configurator);
String channelName1 = "channel1";
String channelName2 = "channel2";
BroadcastEndpointFactory jgroupsBroadcastCfg1 = new ChannelBroadcastEndpointFactory(channel, channelName1);
BroadcastEndpointFactory jgroupsBroadcastCfg2 = new JGroupsFileBroadcastEndpointFactory().setChannelName(channelName2).setFile(jgroupsConfigString);
DiscoveryGroupConfiguration dcConfig1 = new DiscoveryGroupConfiguration().setName("dg1").setRefreshTimeout(5000).setDiscoveryInitialWaitTimeout(5000).setBroadcastEndpointFactory(jgroupsBroadcastCfg1);
DiscoveryGroupConfiguration dcConfig2 = new DiscoveryGroupConfiguration().setName("dg2").setRefreshTimeout(5000).setDiscoveryInitialWaitTimeout(5000).setBroadcastEndpointFactory(jgroupsBroadcastCfg2);
jmsServer.getActiveMQServer().getConfiguration().getDiscoveryGroupConfigurations().put(dcConfig1.getName(), dcConfig1);
jmsServer.getActiveMQServer().getConfiguration().getDiscoveryGroupConfigurations().put(dcConfig2.getName(), dcConfig2);
jmsServer.createConnectionFactory("ConnectionFactory1", false, JMSFactoryType.CF, dcConfig1.getName(), "/ConnectionFactory1");
jmsServer.createConnectionFactory("ConnectionFactory2", false, JMSFactoryType.CF, dcConfig2.getName(), "/ConnectionFactory2");
testQueue = createQueue("testQueueFor1389");
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
Aggregations