Search in sources :

Example 1 with DefaultConnectionContext

use of org.apache.oozie.jms.DefaultConnectionContext in project oozie by apache.

the class JMSAccessorService method getConnectionContextImpl.

private ConnectionContext getConnectionContextImpl() {
    Class<?> defaultClazz = ConfigurationService.getClass(conf, JMS_CONNECTION_CONTEXT_IMPL);
    ConnectionContext connCtx = null;
    if (defaultClazz == DefaultConnectionContext.class) {
        connCtx = new DefaultConnectionContext();
    } else {
        connCtx = (ConnectionContext) ReflectionUtils.newInstance(defaultClazz, null);
    }
    return connCtx;
}
Also used : DefaultConnectionContext(org.apache.oozie.jms.DefaultConnectionContext) ConnectionContext(org.apache.oozie.jms.ConnectionContext) DefaultConnectionContext(org.apache.oozie.jms.DefaultConnectionContext)

Example 2 with DefaultConnectionContext

use of org.apache.oozie.jms.DefaultConnectionContext in project oozie by apache.

the class TestJMSAccessorService method testConnectionContext.

@Test
public void testConnectionContext() throws ServiceException {
    try {
        services.destroy();
        services = super.setupServicesForHCatalog();
        Configuration conf = services.getConf();
        // set the connection factory name
        String jmsURL = "hcat://${1}.${2}.server.com:8020=java.naming.factory.initial#" + "org.apache.activemq.jndi.ActiveMQInitialContextFactory" + ";java.naming.provider.url#vm://localhost?broker.persistent=false;" + "connectionFactoryNames#dynamicFactories/hcat.prod.${1}";
        conf.set(HCatAccessorService.JMS_CONNECTIONS_PROPERTIES, jmsURL);
        services.init();
        HCatAccessorService hcatService = services.get(HCatAccessorService.class);
        JMSConnectionInfo connInfo = hcatService.getJMSConnectionInfo(new URI("hcat://hcatserver.blue.server.com:8020"));
        assertEquals("java.naming.factory.initial#org.apache.activemq.jndi.ActiveMQInitialContextFactory;java.naming.provider.url#" + "vm://localhost?broker.persistent=false;connectionFactoryNames#dynamicFactories/hcat.prod.hcatserver", connInfo.getJNDIPropertiesString());
        ConnectionContext ctx1 = new DefaultConnectionContext();
        ctx1.createConnection(connInfo.getJNDIProperties());
        BrokerService broker = new BrokerService();
        broker.setDataDirectory(getTestCaseDir());
        // Without this stop testConnectionRetry fails with
        // javax.management.InstanceAlreadyExistsException: org.apache.activemq:BrokerName=localhost,Type=Broker
        broker.stop();
    } catch (Exception e) {
        e.printStackTrace();
        fail("Unexpected exception " + e);
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) DefaultConnectionContext(org.apache.oozie.jms.DefaultConnectionContext) JMSConnectionInfo(org.apache.oozie.jms.JMSConnectionInfo) ConnectionContext(org.apache.oozie.jms.ConnectionContext) DefaultConnectionContext(org.apache.oozie.jms.DefaultConnectionContext) URI(java.net.URI) BrokerService(org.apache.activemq.broker.BrokerService) Test(org.junit.Test)

Aggregations

ConnectionContext (org.apache.oozie.jms.ConnectionContext)2 DefaultConnectionContext (org.apache.oozie.jms.DefaultConnectionContext)2 URI (java.net.URI)1 BrokerService (org.apache.activemq.broker.BrokerService)1 Configuration (org.apache.hadoop.conf.Configuration)1 JMSConnectionInfo (org.apache.oozie.jms.JMSConnectionInfo)1 Test (org.junit.Test)1