Search in sources :

Example 1 with JGroupsFileBroadcastEndpoint

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

the class SimpleJNDIClientTest method testRemoteCFWithJgroupsWithTransportConfigFile.

@Test
public void testRemoteCFWithJgroupsWithTransportConfigFile() throws Exception {
    Hashtable<String, String> props = new Hashtable<>();
    props.put(Context.INITIAL_CONTEXT_FACTORY, org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory.class.getCanonicalName());
    props.put("connectionFactory.myConnectionFactory", "jgroups://testChannelName?file=test-jgroups-file_ping.xml&" + ActiveMQInitialContextFactory.REFRESH_TIMEOUT + "=5000&" + ActiveMQInitialContextFactory.DISCOVERY_INITIAL_WAIT_TIMEOUT + "=6000");
    Context ctx = new InitialContext(props);
    ActiveMQConnectionFactory cf = (ActiveMQConnectionFactory) ctx.lookup("myConnectionFactory");
    DiscoveryGroupConfiguration discoveryGroupConfiguration = cf.getDiscoveryGroupConfiguration();
    Assert.assertEquals(5000, discoveryGroupConfiguration.getRefreshTimeout());
    Assert.assertEquals(6000, discoveryGroupConfiguration.getDiscoveryInitialWaitTimeout());
    BroadcastEndpoint broadcastEndpoint = cf.getDiscoveryGroupConfiguration().getBroadcastEndpointFactory().createBroadcastEndpoint();
    Assert.assertTrue(broadcastEndpoint instanceof JGroupsFileBroadcastEndpoint);
    broadcastEndpoint.close(false);
}
Also used : Context(javax.naming.Context) InitialContext(javax.naming.InitialContext) ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) JGroupsFileBroadcastEndpoint(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpoint) BroadcastEndpoint(org.apache.activemq.artemis.api.core.BroadcastEndpoint) Hashtable(java.util.Hashtable) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) JGroupsFileBroadcastEndpoint(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpoint) ActiveMQInitialContextFactory(org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Aggregations

Hashtable (java.util.Hashtable)1 Context (javax.naming.Context)1 InitialContext (javax.naming.InitialContext)1 BroadcastEndpoint (org.apache.activemq.artemis.api.core.BroadcastEndpoint)1 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)1 JGroupsFileBroadcastEndpoint (org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpoint)1 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)1 ActiveMQInitialContextFactory (org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory)1 Test (org.junit.Test)1