Java Code Examples for org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory#getDiscoveryGroupConfiguration()
The following examples show how to use
org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory#getDiscoveryGroupConfiguration() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleJNDIClientTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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); }
Example 2
Source File: SimpleJNDIClientTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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"); }
Example 3
Source File: SimpleJNDIClientTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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"); }
Example 4
Source File: SimpleJNDIClientTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testRemoteCFWithUDPWithTransportConfig() throws NamingException, JMSException { Hashtable<String, String> props = new Hashtable<>(); props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName()); props.put("connectionFactory.myConnectionFactory", "udp://" + getUDPDiscoveryAddress() + ":" + getUDPDiscoveryPort() + "?" + TransportConstants.LOCAL_ADDRESS_PROP_NAME + "=Server1&" + TransportConstants.LOCAL_PORT_PROP_NAME + "=1198&" + 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()); UDPBroadcastEndpointFactory udpBroadcastEndpointFactory = (UDPBroadcastEndpointFactory) discoveryGroupConfiguration.getBroadcastEndpointFactory(); //these 2 are transient so are ignored Assert.assertNotEquals("Server1", udpBroadcastEndpointFactory.getLocalBindAddress()); Assert.assertNotEquals(1198, udpBroadcastEndpointFactory.getLocalBindPort()); Assert.assertEquals(getUDPDiscoveryAddress(), udpBroadcastEndpointFactory.getGroupAddress()); Assert.assertEquals(getUDPDiscoveryPort(), udpBroadcastEndpointFactory.getGroupPort()); }
Example 5
Source File: ConnectionFactorySerializationTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testConnectionFactoryUDP() throws Exception { createDiscoveryFactoryUDP(); 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 UDPBroadcastEndpointFactory); UDPBroadcastEndpointFactory befc = (UDPBroadcastEndpointFactory) dgc.getBroadcastEndpointFactory(); Assert.assertEquals(Integer.parseInt(System.getProperty("org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory.localBindPort", "-1")), befc.getLocalBindPort()); Assert.assertEquals(System.getProperty("org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory.localBindAddress"), befc.getLocalBindAddress()); Assert.assertEquals(getUDPDiscoveryPort(), befc.getGroupPort()); Assert.assertEquals(getUDPDiscoveryAddress(), befc.getGroupAddress()); }
Example 6
Source File: ConnectionFactorySerializationTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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()); }
Example 7
Source File: ConnectionFactorySerializationTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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()); }
Example 8
Source File: JGroupsSchema.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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); }
Example 9
Source File: ConnectionFactoryURITest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testJGroupsFileURI() throws Exception { DiscoveryGroupConfiguration discoveryGroupConfiguration = new DiscoveryGroupConfiguration(); JGroupsFileBroadcastEndpointFactory endpointFactory = new JGroupsFileBroadcastEndpointFactory().setChannelName("channel-name").setFile("channel-file.xml"); 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 befc = dgc.getBroadcastEndpointFactory(); Assert.assertNotNull(befc); Assert.assertTrue(befc instanceof JGroupsFileBroadcastEndpointFactory); Assert.assertEquals(dgc.getName(), "foo"); Assert.assertEquals(dgc.getDiscoveryInitialWaitTimeout(), 5678); Assert.assertEquals(dgc.getRefreshTimeout(), 12345); JGroupsFileBroadcastEndpointFactory fileBroadcastEndpointFactory = (JGroupsFileBroadcastEndpointFactory) befc; Assert.assertEquals(fileBroadcastEndpointFactory.getFile(), "channel-file.xml"); Assert.assertEquals(fileBroadcastEndpointFactory.getChannelName(), "channel-name"); BeanUtilsBean bean = new BeanUtilsBean(); checkEquals(bean, connectionFactoryWithHA, factory); }
Example 10
Source File: ConnectionFactoryURITest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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); }
Example 11
Source File: UDPSchema.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected URI internalNewURI(ActiveMQConnectionFactory bean) throws Exception { DiscoveryGroupConfiguration dgc = bean.getDiscoveryGroupConfiguration(); UDPBroadcastEndpointFactory endpoint = (UDPBroadcastEndpointFactory) dgc.getBroadcastEndpointFactory(); String query = BeanSupport.getData(UDPServerLocatorSchema.IGNORED, bean, dgc, endpoint); dgc.setBroadcastEndpointFactory(endpoint); return new URI(SchemaConstants.UDP, null, endpoint.getGroupAddress(), endpoint.getGroupPort(), null, query, null); }
Example 12
Source File: ConnectionFactoryURITest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testUDPURI() throws Exception { DiscoveryGroupConfiguration discoveryGroupConfiguration = new DiscoveryGroupConfiguration(); UDPBroadcastEndpointFactory endpoint = new UDPBroadcastEndpointFactory(); endpoint.setGroupPort(3333).setGroupAddress("wahey").setLocalBindPort(555).setLocalBindAddress("uhuh"); discoveryGroupConfiguration.setName("foo").setRefreshTimeout(12345).setDiscoveryInitialWaitTimeout(5678).setBroadcastEndpointFactory(endpoint); ActiveMQConnectionFactory connectionFactoryWithHA = ActiveMQJMSClient.createConnectionFactoryWithHA(discoveryGroupConfiguration, JMSFactoryType.CF); URI tcp = parser.createSchema("udp", connectionFactoryWithHA); ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(tcp.toString()); DiscoveryGroupConfiguration dgc = factory.getDiscoveryGroupConfiguration(); Assert.assertNotNull(dgc); BroadcastEndpointFactory befc = dgc.getBroadcastEndpointFactory(); Assert.assertNotNull(befc); Assert.assertTrue(befc instanceof UDPBroadcastEndpointFactory); UDPBroadcastEndpointFactory ubgc = (UDPBroadcastEndpointFactory) befc; Assert.assertEquals("wahey", ubgc.getGroupAddress()); Assert.assertEquals(3333, ubgc.getGroupPort()); //these 2 are transient // These will take the System.properties used on the testsuite, // for that reason we take them as != instead of checking for null Assert.assertNotEquals("uhuh", ubgc.getLocalBindAddress()); Assert.assertNotEquals(555, ubgc.getLocalBindPort()); Assert.assertEquals("foo", dgc.getName()); Assert.assertEquals(5678, dgc.getDiscoveryInitialWaitTimeout()); Assert.assertEquals(12345, dgc.getRefreshTimeout()); BeanUtilsBean bean = new BeanUtilsBean(); checkEquals(bean, connectionFactoryWithHA, factory); }