Search in sources :

Example 16 with JGroupsFileBroadcastEndpointFactory

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

the class ConnectionFactorySerializationTest method testConnectionFactoryJgroupsFile.

@Test
public void testConnectionFactoryJgroupsFile() throws Exception {
    createDiscoveryFactoryJGroupsFile();
    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 JGroupsFileBroadcastEndpointFactory);
    JGroupsFileBroadcastEndpointFactory befc = (JGroupsFileBroadcastEndpointFactory) dgc.getBroadcastEndpointFactory();
    Assert.assertEquals("myChannel", befc.getChannelName());
    Assert.assertEquals("/META-INF/myfile.xml", befc.getFile());
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) JGroupsFileBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) Test(org.junit.Test)

Example 17 with JGroupsFileBroadcastEndpointFactory

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

JGroupsFileBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory)17 BroadcastEndpointFactory (org.apache.activemq.artemis.api.core.BroadcastEndpointFactory)11 Test (org.junit.Test)9 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)8 UDPBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory)7 URI (java.net.URI)4 BroadcastEndpoint (org.apache.activemq.artemis.api.core.BroadcastEndpoint)4 JGroupsPropertiesBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory)4 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)4 ChannelBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory)3 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)3 NotSerializableException (java.io.NotSerializableException)2 ArrayList (java.util.ArrayList)2 JChannel (org.jgroups.JChannel)2 IOException (java.io.IOException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 BroadcastGroupConfiguration (org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration)1 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)1 DiscoveryEntry (org.apache.activemq.artemis.core.cluster.DiscoveryEntry)1 DiscoveryGroup (org.apache.activemq.artemis.core.cluster.DiscoveryGroup)1