Search in sources :

Example 1 with JGroupsPropertiesBroadcastEndpointFactory

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

the class JGroupsServerLocatorSchema method internalNewURI.

@Override
protected URI internalNewURI(ServerLocator bean) throws Exception {
    DiscoveryGroupConfiguration dgc = bean.getDiscoveryGroupConfiguration();
    BroadcastEndpointFactory endpoint = dgc.getBroadcastEndpointFactory();
    String auth;
    if (endpoint instanceof JGroupsFileBroadcastEndpointFactory) {
        auth = ((JGroupsFileBroadcastEndpointFactory) endpoint).getChannelName();
    } else if (endpoint instanceof JGroupsPropertiesBroadcastEndpointFactory) {
        auth = ((JGroupsPropertiesBroadcastEndpointFactory) endpoint).getChannelName();
    } else {
        throw new NotSerializableException(endpoint + "not serializable");
    }
    String query = BeanSupport.getData(null, bean, dgc, endpoint);
    dgc.setBroadcastEndpointFactory(endpoint);
    return new URI(SchemaConstants.JGROUPS, null, auth, -1, null, query, null);
}
Also used : NotSerializableException(java.io.NotSerializableException) JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) JGroupsFileBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) URI(java.net.URI) JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) JGroupsFileBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory) BroadcastEndpointFactory(org.apache.activemq.artemis.api.core.BroadcastEndpointFactory)

Example 2 with JGroupsPropertiesBroadcastEndpointFactory

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

the class JGroupsServerLocatorSchema method getDiscoveryGroupConfiguration.

public static DiscoveryGroupConfiguration getDiscoveryGroupConfiguration(URI uri, Map<String, String> query, String name) throws Exception {
    BroadcastEndpointFactory endpointFactory;
    if (query.containsKey("file")) {
        endpointFactory = new JGroupsFileBroadcastEndpointFactory().setChannelName(uri.getAuthority());
    } else {
        endpointFactory = new JGroupsPropertiesBroadcastEndpointFactory().setChannelName(uri.getAuthority());
    }
    BeanSupport.setData(uri, endpointFactory, query);
    DiscoveryGroupConfiguration dcConfig = new DiscoveryGroupConfiguration().setName(name).setBroadcastEndpointFactory(endpointFactory);
    BeanSupport.setData(uri, dcConfig, query);
    return dcConfig;
}
Also used : JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) JGroupsFileBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) JGroupsFileBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory) BroadcastEndpointFactory(org.apache.activemq.artemis.api.core.BroadcastEndpointFactory)

Example 3 with JGroupsPropertiesBroadcastEndpointFactory

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

the class ConnectionFactoryURITest method testJGroupsKeyValue.

@Test
public void testJGroupsKeyValue() throws Exception {
    ActiveMQConnectionFactory factory = parser.newObject(new URI("jgroups://channel-name?properties=param=value;param2=value2&test=33"), null);
    Assert.assertTrue(ActiveMQJMSConnectionFactory.class.getName().equals(factory.getClass().getName()));
    JGroupsPropertiesBroadcastEndpointFactory broadcastEndpointFactory = (JGroupsPropertiesBroadcastEndpointFactory) factory.getDiscoveryGroupConfiguration().getBroadcastEndpointFactory();
    Assert.assertEquals(broadcastEndpointFactory.getProperties(), "param=value;param2=value2");
    Assert.assertEquals(broadcastEndpointFactory.getChannelName(), "channel-name");
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) URI(java.net.URI) Test(org.junit.Test)

Example 4 with JGroupsPropertiesBroadcastEndpointFactory

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

the class SimpleJNDIClientTest method testRemoteCFWithJgroupsWithTransportConfigNullProps.

@Test
public void testRemoteCFWithJgroupsWithTransportConfigNullProps() throws Exception {
    Hashtable<String, String> props = new Hashtable<>();
    props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName());
    props.put("connectionFactory.ConnectionFactory", "jgroups://testChannelName?" + ActiveMQInitialContextFactory.REFRESH_TIMEOUT + "=5000&" + ActiveMQInitialContextFactory.DISCOVERY_INITIAL_WAIT_TIMEOUT + "=6000");
    Context ctx = new InitialContext(props);
    ActiveMQConnectionFactory cf = (ActiveMQConnectionFactory) ctx.lookup("ConnectionFactory");
    DiscoveryGroupConfiguration discoveryGroupConfiguration = cf.getDiscoveryGroupConfiguration();
    Assert.assertEquals(5000, discoveryGroupConfiguration.getRefreshTimeout());
    Assert.assertEquals(6000, discoveryGroupConfiguration.getDiscoveryInitialWaitTimeout());
    BroadcastEndpointFactory broadcastEndpointFactory = cf.getDiscoveryGroupConfiguration().getBroadcastEndpointFactory();
    Assert.assertTrue(broadcastEndpointFactory instanceof JGroupsPropertiesBroadcastEndpointFactory);
    JGroupsPropertiesBroadcastEndpointFactory endpointFactory = (JGroupsPropertiesBroadcastEndpointFactory) broadcastEndpointFactory;
    Assert.assertEquals(endpointFactory.getProperties(), null);
    Assert.assertEquals(endpointFactory.getChannelName(), "testChannelName");
}
Also used : Context(javax.naming.Context) InitialContext(javax.naming.InitialContext) ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) Hashtable(java.util.Hashtable) JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) ActiveMQInitialContextFactory(org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory) InitialContext(javax.naming.InitialContext) JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) BroadcastEndpointFactory(org.apache.activemq.artemis.api.core.BroadcastEndpointFactory) Test(org.junit.Test)

Example 5 with JGroupsPropertiesBroadcastEndpointFactory

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

the class SimpleJNDIClientTest method testRemoteCFWithJgroupsWithTransportConfigProps.

@Test
public void testRemoteCFWithJgroupsWithTransportConfigProps() throws Exception {
    Hashtable<String, String> props = new Hashtable<>();
    props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName());
    props.put("connectionFactory.ConnectionFactory", "jgroups://testChannelName?properties=param=value&" + ActiveMQInitialContextFactory.REFRESH_TIMEOUT + "=5000&" + ActiveMQInitialContextFactory.DISCOVERY_INITIAL_WAIT_TIMEOUT + "=6000");
    Context ctx = new InitialContext(props);
    ActiveMQConnectionFactory cf = (ActiveMQConnectionFactory) ctx.lookup("ConnectionFactory");
    DiscoveryGroupConfiguration discoveryGroupConfiguration = cf.getDiscoveryGroupConfiguration();
    Assert.assertEquals(5000, discoveryGroupConfiguration.getRefreshTimeout());
    Assert.assertEquals(6000, discoveryGroupConfiguration.getDiscoveryInitialWaitTimeout());
    BroadcastEndpointFactory broadcastEndpointFactory = cf.getDiscoveryGroupConfiguration().getBroadcastEndpointFactory();
    Assert.assertTrue(broadcastEndpointFactory instanceof JGroupsPropertiesBroadcastEndpointFactory);
    JGroupsPropertiesBroadcastEndpointFactory endpointFactory = (JGroupsPropertiesBroadcastEndpointFactory) broadcastEndpointFactory;
    Assert.assertEquals(endpointFactory.getProperties(), "param=value");
    Assert.assertEquals(endpointFactory.getChannelName(), "testChannelName");
}
Also used : Context(javax.naming.Context) InitialContext(javax.naming.InitialContext) ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) Hashtable(java.util.Hashtable) JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) ActiveMQInitialContextFactory(org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory) InitialContext(javax.naming.InitialContext) JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) BroadcastEndpointFactory(org.apache.activemq.artemis.api.core.BroadcastEndpointFactory) Test(org.junit.Test)

Aggregations

JGroupsPropertiesBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory)9 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)8 BroadcastEndpointFactory (org.apache.activemq.artemis.api.core.BroadcastEndpointFactory)6 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)5 Test (org.junit.Test)5 URI (java.net.URI)4 JGroupsFileBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory)4 UDPBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory)3 NotSerializableException (java.io.NotSerializableException)2 Hashtable (java.util.Hashtable)2 Context (javax.naming.Context)2 InitialContext (javax.naming.InitialContext)2 ActiveMQInitialContextFactory (org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory)2 ArrayList (java.util.ArrayList)1 BeanUtilsBean (org.apache.commons.beanutils.BeanUtilsBean)1