Search in sources :

Example 6 with JGroupsPropertiesBroadcastEndpointFactory

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

the class ConnectionFactorySerializationTest method createDiscoveryFactoryJGroupsProperties.

private void createDiscoveryFactoryJGroupsProperties() throws Exception {
    // Deploy a connection factory with discovery
    List<String> bindings = new ArrayList<>();
    bindings.add("MyConnectionFactory");
    JGroupsPropertiesBroadcastEndpointFactory config = new JGroupsPropertiesBroadcastEndpointFactory().setChannelName("myChannel").setProperties("param=1,param2=2");
    DiscoveryGroupConfiguration dcConfig = new DiscoveryGroupConfiguration().setName("dg1").setRefreshTimeout(5000).setDiscoveryInitialWaitTimeout(5000).setBroadcastEndpointFactory(config);
    jmsServer.getActiveMQServer().getConfiguration().getDiscoveryGroupConfigurations().put(dcConfig.getName(), dcConfig);
    jmsServer.createConnectionFactory("MyConnectionFactory", false, JMSFactoryType.CF, dcConfig.getName(), "/MyConnectionFactory");
}
Also used : ArrayList(java.util.ArrayList) JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)

Example 7 with JGroupsPropertiesBroadcastEndpointFactory

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

the class JGroupsSchema method internalNewURI.

@Override
protected URI internalNewURI(ActiveMQConnectionFactory 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 8 with JGroupsPropertiesBroadcastEndpointFactory

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

the class ConnectionFactoryURITest method testJGroupsPropertiesURI.

@Test
public void testJGroupsPropertiesURI() throws Exception {
    DiscoveryGroupConfiguration discoveryGroupConfiguration = new DiscoveryGroupConfiguration();
    JGroupsPropertiesBroadcastEndpointFactory endpointFactory = new JGroupsPropertiesBroadcastEndpointFactory().setChannelName("channel-name").setProperties("param=val,param2-val2");
    discoveryGroupConfiguration.setName("foo").setRefreshTimeout(12345).setDiscoveryInitialWaitTimeout(5678).setBroadcastEndpointFactory(endpointFactory);
    ActiveMQConnectionFactory connectionFactoryWithHA = ActiveMQJMSClient.createConnectionFactoryWithHA(discoveryGroupConfiguration, JMSFactoryType.CF);
    URI tcp = parser.createSchema("jgroups", connectionFactoryWithHA);
    ActiveMQConnectionFactory factory = parser.newObject(tcp, null);
    DiscoveryGroupConfiguration dgc = factory.getDiscoveryGroupConfiguration();
    Assert.assertNotNull(dgc);
    BroadcastEndpointFactory broadcastEndpointFactory = dgc.getBroadcastEndpointFactory();
    Assert.assertNotNull(broadcastEndpointFactory);
    Assert.assertTrue(broadcastEndpointFactory instanceof JGroupsPropertiesBroadcastEndpointFactory);
    Assert.assertEquals(dgc.getName(), "foo");
    Assert.assertEquals(dgc.getDiscoveryInitialWaitTimeout(), 5678);
    Assert.assertEquals(dgc.getRefreshTimeout(), 12345);
    JGroupsPropertiesBroadcastEndpointFactory propertiesBroadcastEndpointFactory = (JGroupsPropertiesBroadcastEndpointFactory) broadcastEndpointFactory;
    Assert.assertEquals(propertiesBroadcastEndpointFactory.getProperties(), "param=val,param2-val2");
    Assert.assertEquals(propertiesBroadcastEndpointFactory.getChannelName(), "channel-name");
    BeanUtilsBean bean = new BeanUtilsBean();
    checkEquals(bean, connectionFactoryWithHA, factory);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) BeanUtilsBean(org.apache.commons.beanutils.BeanUtilsBean) JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) URI(java.net.URI) JGroupsFileBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory) 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 9 with JGroupsPropertiesBroadcastEndpointFactory

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

the class ConnectionFactorySerializationTest method testConnectionFactoryJgroupsProperties.

@Test
public void testConnectionFactoryJgroupsProperties() throws Exception {
    createDiscoveryFactoryJGroupsProperties();
    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 JGroupsPropertiesBroadcastEndpointFactory);
    JGroupsPropertiesBroadcastEndpointFactory befc = (JGroupsPropertiesBroadcastEndpointFactory) dgc.getBroadcastEndpointFactory();
    Assert.assertEquals("myChannel", befc.getChannelName());
    Assert.assertEquals("param=1,param2=2", befc.getProperties());
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) 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