Search in sources :

Example 1 with ChannelBroadcastEndpointFactory

use of org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory in project wildfly by wildfly.

the class BroadcastGroupAdd method createBroadcastGroupConfiguration.

static BroadcastGroupConfiguration createBroadcastGroupConfiguration(final String name, final BroadcastGroupConfiguration config, final JChannel channel, final String channelName) throws Exception {
    final long broadcastPeriod = config.getBroadcastPeriod();
    final List<String> connectorRefs = config.getConnectorInfos();
    final BroadcastEndpointFactory endpointFactory = new ChannelBroadcastEndpointFactory(channel, channelName);
    return new BroadcastGroupConfiguration().setName(name).setBroadcastPeriod(broadcastPeriod).setConnectorInfos(connectorRefs).setEndpointFactory(endpointFactory);
}
Also used : ChannelBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory) BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration) ChannelBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) BroadcastEndpointFactory(org.apache.activemq.artemis.api.core.BroadcastEndpointFactory)

Example 2 with ChannelBroadcastEndpointFactory

use of org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory in project wildfly by wildfly.

the class DiscoveryGroupAdd method createDiscoveryGroupConfiguration.

static DiscoveryGroupConfiguration createDiscoveryGroupConfiguration(final String name, final DiscoveryGroupConfiguration config, final JChannel channel, final String channelName) throws Exception {
    final long refreshTimeout = config.getRefreshTimeout();
    final long initialWaitTimeout = config.getDiscoveryInitialWaitTimeout();
    final BroadcastEndpointFactory endpointFactory = new ChannelBroadcastEndpointFactory(channel, channelName);
    return new DiscoveryGroupConfiguration().setName(name).setRefreshTimeout(refreshTimeout).setDiscoveryInitialWaitTimeout(initialWaitTimeout).setBroadcastEndpointFactory(endpointFactory);
}
Also used : ChannelBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) ChannelBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) BroadcastEndpointFactory(org.apache.activemq.artemis.api.core.BroadcastEndpointFactory)

Example 3 with ChannelBroadcastEndpointFactory

use of org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory in project activemq-artemis by apache.

the class ActiveMQResourceAdapter method createBroadcastEndpointFactory.

protected BroadcastEndpointFactory createBroadcastEndpointFactory(final ConnectionFactoryProperties overrideProperties) {
    String discoveryAddress = overrideProperties.getDiscoveryAddress() != null ? overrideProperties.getDiscoveryAddress() : getDiscoveryAddress();
    if (discoveryAddress != null) {
        Integer discoveryPort = overrideProperties.getDiscoveryPort() != null ? overrideProperties.getDiscoveryPort() : getDiscoveryPort();
        if (discoveryPort == null) {
            discoveryPort = ActiveMQClient.DEFAULT_DISCOVERY_PORT;
        }
        String localBindAddress = overrideProperties.getDiscoveryLocalBindAddress() != null ? overrideProperties.getDiscoveryLocalBindAddress() : raProperties.getDiscoveryLocalBindAddress();
        return new UDPBroadcastEndpointFactory().setGroupAddress(discoveryAddress).setGroupPort(discoveryPort).setLocalBindAddress(localBindAddress).setLocalBindPort(-1);
    }
    String jgroupsChannel = overrideProperties.getJgroupsChannelName() != null ? overrideProperties.getJgroupsChannelName() : getJgroupsChannelName();
    String jgroupsLocatorClassName = raProperties.getJgroupsChannelLocatorClass();
    if (jgroupsLocatorClassName != null) {
        String jchannelRefName = raProperties.getJgroupsChannelRefName();
        JChannel jchannel = ActiveMQRaUtils.locateJGroupsChannel(jgroupsLocatorClassName, jchannelRefName);
        return new ChannelBroadcastEndpointFactory(jchannel, jgroupsChannel);
    }
    String jgroupsFileName = overrideProperties.getJgroupsFile() != null ? overrideProperties.getJgroupsFile() : getJgroupsFile();
    if (jgroupsFileName != null) {
        return new JGroupsFileBroadcastEndpointFactory().setChannelName(jgroupsChannel).setFile(jgroupsFileName);
    }
    return null;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ChannelBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory) JChannel(org.jgroups.JChannel) JGroupsFileBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory)

Example 4 with ChannelBroadcastEndpointFactory

use of org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory 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 5 with ChannelBroadcastEndpointFactory

use of org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory 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

ChannelBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory)5 BroadcastEndpointFactory (org.apache.activemq.artemis.api.core.BroadcastEndpointFactory)4 UDPBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory)3 JChannel (org.jgroups.JChannel)3 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)2 JGroupsFileBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory)2 PlainConfigurator (org.jgroups.conf.PlainConfigurator)2 IOException (java.io.IOException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 BroadcastEndpoint (org.apache.activemq.artemis.api.core.BroadcastEndpoint)1 BroadcastGroupConfiguration (org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration)1 Before (org.junit.Before)1 Test (org.junit.Test)1