Search in sources :

Example 1 with PlainConfigurator

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) {
        }
    }
}
Also used : ChannelBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory) BroadcastEndpoint(org.apache.activemq.artemis.api.core.BroadcastEndpoint) JChannel(org.jgroups.JChannel) PlainConfigurator(org.jgroups.conf.PlainConfigurator) BroadcastEndpointFactory(org.apache.activemq.artemis.api.core.BroadcastEndpointFactory) ChannelBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory) Test(org.junit.Test)

Example 2 with PlainConfigurator

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;
    }
}
Also used : ChannelBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory) JChannel(org.jgroups.JChannel) PlainConfigurator(org.jgroups.conf.PlainConfigurator) JGroupsFileBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) IOException(java.io.IOException) JGroupsFileBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory) BroadcastEndpointFactory(org.apache.activemq.artemis.api.core.BroadcastEndpointFactory) ChannelBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory) Before(org.junit.Before)

Aggregations

BroadcastEndpointFactory (org.apache.activemq.artemis.api.core.BroadcastEndpointFactory)2 ChannelBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory)2 JChannel (org.jgroups.JChannel)2 PlainConfigurator (org.jgroups.conf.PlainConfigurator)2 IOException (java.io.IOException)1 BroadcastEndpoint (org.apache.activemq.artemis.api.core.BroadcastEndpoint)1 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)1 JGroupsFileBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory)1 Before (org.junit.Before)1 Test (org.junit.Test)1