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);
}
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);
}
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;
}
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) {
}
}
}
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;
}
}
Aggregations