Search in sources :

Example 1 with ConnectionFactoryResource

use of org.apache.camel.component.sjms.jms.ConnectionFactoryResource in project camel by apache.

the class TransactedTopicProducerTest method createCamelContext.

/*
     * @see org.apache.camel.test.junit4.CamelTestSupport#createCamelContext()
     * @return
     * @throws Exception
     */
@Override
protected CamelContext createCamelContext() throws Exception {
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
    ConnectionFactoryResource connectionResource = new ConnectionFactoryResource();
    connectionResource.setConnectionFactory(connectionFactory);
    connectionResource.setClientId("test-connection-1");
    CamelContext camelContext = super.createCamelContext();
    SjmsComponent component = new SjmsComponent();
    component.setConnectionResource(connectionResource);
    component.setConnectionCount(1);
    camelContext.addComponent("sjms", component);
    return camelContext;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) CamelContext(org.apache.camel.CamelContext) SjmsComponent(org.apache.camel.component.sjms.SjmsComponent) ConnectionFactoryResource(org.apache.camel.component.sjms.jms.ConnectionFactoryResource)

Example 2 with ConnectionFactoryResource

use of org.apache.camel.component.sjms.jms.ConnectionFactoryResource in project camel by apache.

the class InOnlyTopicDurableConsumerTest method createCamelContext.

/*
     * @see org.apache.camel.test.junit4.CamelTestSupport#createCamelContext()
     *
     * @return
     * @throws Exception
     */
@Override
protected CamelContext createCamelContext() throws Exception {
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(BROKER_URI);
    ConnectionFactoryResource connectionResource = new ConnectionFactoryResource();
    connectionResource.setConnectionFactory(connectionFactory);
    connectionResource.setClientId(CONNECTION_ID);
    CamelContext camelContext = super.createCamelContext();
    SjmsComponent component = new SjmsComponent();
    component.setConnectionResource(connectionResource);
    component.setConnectionCount(1);
    camelContext.addComponent("sjms", component);
    return camelContext;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) CamelContext(org.apache.camel.CamelContext) SjmsComponent(org.apache.camel.component.sjms.SjmsComponent) ConnectionFactoryResource(org.apache.camel.component.sjms.jms.ConnectionFactoryResource)

Example 3 with ConnectionFactoryResource

use of org.apache.camel.component.sjms.jms.ConnectionFactoryResource in project camel by apache.

the class SjmsEndpoint method createConnectionResource.

protected ConnectionResource createConnectionResource(Object source) {
    if (getConnectionFactory() == null) {
        throw new IllegalArgumentException(String.format("ConnectionResource or ConnectionFactory must be configured for %s", this));
    }
    try {
        logger.debug("Creating ConnectionResource with connectionCount: {} using ConnectionFactory", getConnectionCount(), getConnectionFactory());
        // We always use a connection pool, even for a pool of 1
        ConnectionFactoryResource connections = new ConnectionFactoryResource(getConnectionCount(), getConnectionFactory(), getComponent().getConnectionUsername(), getComponent().getConnectionPassword(), getComponent().getConnectionClientId(), getComponent().getConnectionMaxWait(), getComponent().isConnectionTestOnBorrow());
        if (exceptionListener != null) {
            connections.setExceptionListener(exceptionListener);
        } else {
            // add a exception listener that logs so we can see any errors that happens
            ExceptionListener listener = new SjmsLoggingExceptionListener(new LoggingExceptionHandler(getCamelContext(), source.getClass()), isErrorHandlerLogStackTrace());
            connections.setExceptionListener(listener);
        }
        connections.fillPool();
        return connections;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
Also used : LoggingExceptionHandler(org.apache.camel.support.LoggingExceptionHandler) ConnectionFactoryResource(org.apache.camel.component.sjms.jms.ConnectionFactoryResource) ExceptionListener(javax.jms.ExceptionListener)

Example 4 with ConnectionFactoryResource

use of org.apache.camel.component.sjms.jms.ConnectionFactoryResource in project camel by apache.

the class InOnlyTopicDurableConsumerTest method createCamelContext.

/*
     * @see org.apache.camel.test.junit4.CamelTestSupport#createCamelContext()
     *
     * @return
     * @throws Exception
     */
@Override
protected CamelContext createCamelContext() throws Exception {
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(BROKER_URI);
    ConnectionFactoryResource connectionResource = new ConnectionFactoryResource();
    connectionResource.setConnectionFactory(connectionFactory);
    connectionResource.setClientId(CONNECTION_ID);
    CamelContext camelContext = super.createCamelContext();
    Sjms2Component component = new Sjms2Component();
    component.setConnectionResource(connectionResource);
    component.setConnectionCount(1);
    camelContext.addComponent("sjms2", component);
    return camelContext;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) CamelContext(org.apache.camel.CamelContext) ConnectionFactoryResource(org.apache.camel.component.sjms.jms.ConnectionFactoryResource) Sjms2Component(org.apache.camel.component.sjms2.Sjms2Component)

Example 5 with ConnectionFactoryResource

use of org.apache.camel.component.sjms.jms.ConnectionFactoryResource in project ddf by codice.

the class CoreProducerConsumerExample method createCamelContext.

private void createCamelContext() throws Exception {
    CamelContext camelContext = getContext();
    ActiveMQConnectionFactory factory = ActiveMQJMSClient.createConnectionFactory("(tcp://0.0.0.0:5672,tcp://0.0.0.0:61617)?ha=true;sslEnabled=true;enabledCipherSuites=TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;enabledProtocols=TLSv1.1,TLSv1.2", "name");
    factory.setRetryInterval(1000);
    factory.setRetryIntervalMultiplier(1.0);
    factory.setReconnectAttempts(-1);
    SjmsComponent sjms = new SjmsComponent();
    ConnectionFactoryResource connectionResource = new ConnectionFactoryResource(1, factory, "admin", "admin");
    sjms.setConnectionResource(connectionResource);
    camelContext.addComponent("sjms", sjms);
}
Also used : CamelContext(org.apache.camel.CamelContext) ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) SjmsComponent(org.apache.camel.component.sjms.SjmsComponent) ConnectionFactoryResource(org.apache.camel.component.sjms.jms.ConnectionFactoryResource)

Aggregations

ConnectionFactoryResource (org.apache.camel.component.sjms.jms.ConnectionFactoryResource)5 CamelContext (org.apache.camel.CamelContext)4 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)3 SjmsComponent (org.apache.camel.component.sjms.SjmsComponent)3 ExceptionListener (javax.jms.ExceptionListener)1 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)1 Sjms2Component (org.apache.camel.component.sjms2.Sjms2Component)1 LoggingExceptionHandler (org.apache.camel.support.LoggingExceptionHandler)1