Search in sources :

Example 16 with ActiveMQConnectionFactory

use of org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory in project activemq-artemis by apache.

the class ConnectionFactoryURITest method testUDPAllProperties.

@Test
public void testUDPAllProperties() throws Exception {
    StringBuilder sb = new StringBuilder();
    sb.append("udp://localhost:3030?ha=true");
    BeanUtilsBean bean = new BeanUtilsBean();
    ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(true, (TransportConfiguration) null);
    populate(sb, bean, factory);
    ActiveMQConnectionFactory factory2 = parser.newObject(new URI(sb.toString()), null);
    checkEquals(bean, factory, factory2);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) BeanUtilsBean(org.apache.commons.beanutils.BeanUtilsBean) URI(java.net.URI) Test(org.junit.Test)

Example 17 with ActiveMQConnectionFactory

use of org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory in project activemq-artemis by apache.

the class ConnectionFactoryURITest method testCF.

@Test
public void testCF() throws Exception {
    ActiveMQConnectionFactory factory = parser.newObject(new URI("tcp://localhost:3030?ha=true&type=CF"), null);
    Assert.assertTrue(ActiveMQJMSConnectionFactory.class.getName().equals(factory.getClass().getName()));
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) URI(java.net.URI) Test(org.junit.Test)

Example 18 with ActiveMQConnectionFactory

use of org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory in project activemq-artemis by apache.

the class JGroupsSchema method internalNewObject.

@Override
public ActiveMQConnectionFactory internalNewObject(URI uri, Map<String, String> query, String name) throws Exception {
    JMSConnectionOptions options = newConectionOptions(uri, query);
    DiscoveryGroupConfiguration dcConfig = JGroupsServerLocatorSchema.getDiscoveryGroupConfiguration(uri, query, name);
    ActiveMQConnectionFactory factory;
    if (options.isHa()) {
        factory = ActiveMQJMSClient.createConnectionFactoryWithHA(dcConfig, options.getFactoryTypeEnum());
    } else {
        factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(dcConfig, options.getFactoryTypeEnum());
    }
    return BeanSupport.setData(uri, factory, query);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)

Example 19 with ActiveMQConnectionFactory

use of org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory in project activemq-artemis by apache.

the class ConnectionFactoryURITest method testUDP.

@Test
public void testUDP() throws Exception {
    ActiveMQConnectionFactory factory = parser.newObject(new URI("udp://localhost:3030?ha=true&type=QUEUE_XA_CF"), null);
    Assert.assertTrue(ActiveMQXAQueueConnectionFactory.class.getName().equals(factory.getClass().getName()));
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) URI(java.net.URI) Test(org.junit.Test)

Example 20 with ActiveMQConnectionFactory

use of org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory in project activemq-artemis by apache.

the class ConnectionFactoryURITest method testTCPAllNettyConnectorProperties.

@Test
public void testTCPAllNettyConnectorProperties() throws Exception {
    Map<String, Object> props = new HashMap<>();
    Set<String> allowableConnectorKeys = TransportConstants.ALLOWABLE_CONNECTOR_KEYS;
    StringBuilder sb = new StringBuilder();
    sb.append("tcp://localhost:3030?ha=true");
    populateConnectorParams(props, allowableConnectorKeys, sb);
    ActiveMQConnectionFactory factory = parser.newObject(new URI(sb.toString()), null);
    Map<String, Object> params = factory.getStaticConnectors()[0].getParams();
    Assert.assertEquals(params.get("host"), "localhost");
    Assert.assertEquals(params.get("port"), "3030");
    for (Map.Entry<String, Object> entry : params.entrySet()) {
        if (!entry.getKey().equals("host") && !entry.getKey().equals("port")) {
            Assert.assertEquals(entry.getValue(), props.get(entry.getKey()));
        }
    }
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) HashMap(java.util.HashMap) URI(java.net.URI) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)221 Test (org.junit.Test)141 Connection (javax.jms.Connection)84 Session (javax.jms.Session)84 MessageProducer (javax.jms.MessageProducer)63 MessageConsumer (javax.jms.MessageConsumer)60 TextMessage (javax.jms.TextMessage)49 Queue (javax.jms.Queue)48 ConnectionFactory (javax.jms.ConnectionFactory)35 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)27 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)26 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)24 ActiveMQResourceAdapter (org.apache.activemq.artemis.ra.ActiveMQResourceAdapter)24 URI (java.net.URI)22 JMSException (javax.jms.JMSException)20 Message (javax.jms.Message)19 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)19 InitialContext (javax.naming.InitialContext)16 Context (javax.naming.Context)15 Hashtable (java.util.Hashtable)14