Search in sources :

Example 1 with SjmsComponent

use of org.apache.camel.component.sjms.SjmsComponent in project camel by apache.

the class SjmsBatchConsumerTest method createCamelContext.

@Override
public CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    registry.put("testStrategy", new ListAggregationStrategy());
    ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(broker.getTcpConnectorUri());
    SjmsComponent sjmsComponent = new SjmsComponent();
    sjmsComponent.setConnectionFactory(connectionFactory);
    SjmsBatchComponent sjmsBatchComponent = new SjmsBatchComponent();
    sjmsBatchComponent.setConnectionFactory(connectionFactory);
    CamelContext context = new DefaultCamelContext(registry);
    context.addComponent("sjms", sjmsComponent);
    context.addComponent("sjms-batch", sjmsBatchComponent);
    return context;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) ConnectionFactory(javax.jms.ConnectionFactory) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) SjmsComponent(org.apache.camel.component.sjms.SjmsComponent) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 2 with SjmsComponent

use of org.apache.camel.component.sjms.SjmsComponent in project camel by apache.

the class AsyncConsumerFalseTest method createCamelContext.

protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = super.createCamelContext();
    camelContext.addComponent("async", new MyAsyncComponent());
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
    SjmsComponent component = new SjmsComponent();
    component.setConnectionFactory(connectionFactory);
    camelContext.addComponent("sjms", component);
    return camelContext;
}
Also used : CamelContext(org.apache.camel.CamelContext) ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) MyAsyncComponent(org.apache.camel.component.sjms.support.MyAsyncComponent) SjmsComponent(org.apache.camel.component.sjms.SjmsComponent)

Example 3 with SjmsComponent

use of org.apache.camel.component.sjms.SjmsComponent in project camel by apache.

the class SjmsComponentAutoConfiguration method configureSjmsComponent.

@Lazy
@Bean(name = "sjms-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(SjmsComponent.class)
public SjmsComponent configureSjmsComponent(CamelContext camelContext, SjmsComponentConfiguration configuration) throws Exception {
    SjmsComponent component = new SjmsComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null, false);
    for (Map.Entry<String, Object> entry : parameters.entrySet()) {
        Object value = entry.getValue();
        Class<?> paramClass = value.getClass();
        if (paramClass.getName().endsWith("NestedConfiguration")) {
            Class nestedClass = null;
            try {
                nestedClass = (Class) paramClass.getDeclaredField("CAMEL_NESTED_CLASS").get(null);
                HashMap<String, Object> nestedParameters = new HashMap<>();
                IntrospectionSupport.getProperties(value, nestedParameters, null, false);
                Object nestedProperty = nestedClass.newInstance();
                IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), nestedProperty, nestedParameters);
                entry.setValue(nestedProperty);
            } catch (NoSuchFieldException e) {
            }
        }
    }
    IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters);
    return component;
}
Also used : HashMap(java.util.HashMap) SjmsComponent(org.apache.camel.component.sjms.SjmsComponent) ConditionalOnClass(org.springframework.boot.autoconfigure.condition.ConditionalOnClass) HashMap(java.util.HashMap) Map(java.util.Map) Lazy(org.springframework.context.annotation.Lazy) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnClass(org.springframework.boot.autoconfigure.condition.ConditionalOnClass) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 4 with SjmsComponent

use of org.apache.camel.component.sjms.SjmsComponent in project camel by apache.

the class JmsTestSupport method createCamelContext.

/*
     * @see org.apache.camel.test.junit4.CamelTestSupport#createCamelContext()
     * @return
     * @throws Exception
     */
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = super.createCamelContext();
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerUri);
    connection = connectionFactory.createConnection();
    connection.start();
    session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    SjmsComponent component = new SjmsComponent();
    component.setConnectionCount(1);
    component.setConnectionFactory(connectionFactory);
    camelContext.addComponent("sjms", component);
    return camelContext;
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) SjmsComponent(org.apache.camel.component.sjms.SjmsComponent)

Example 5 with SjmsComponent

use of org.apache.camel.component.sjms.SjmsComponent in project camel by apache.

the class BatchTransactedProducerSupport method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = super.createCamelContext();
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(getBrokerUri());
    SjmsComponent component = new SjmsComponent();
    component.setConnectionFactory(connectionFactory);
    camelContext.addComponent("sjms", component);
    return camelContext;
}
Also used : CamelContext(org.apache.camel.CamelContext) ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) SjmsComponent(org.apache.camel.component.sjms.SjmsComponent)

Aggregations

SjmsComponent (org.apache.camel.component.sjms.SjmsComponent)27 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)19 CamelContext (org.apache.camel.CamelContext)19 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)7 ConnectionFactory (javax.jms.ConnectionFactory)5 Test (org.junit.Test)4 ConnectionFactoryResource (org.apache.camel.component.sjms.jms.ConnectionFactoryResource)3 SimpleRegistry (org.apache.camel.impl.SimpleRegistry)3 MyAsyncComponent (org.apache.camel.component.sjms.support.MyAsyncComponent)2 JmsTemplate (org.springframework.jms.core.JmsTemplate)2 ComponentProxyComponent (io.syndesis.integration.component.proxy.ComponentProxyComponent)1 File (java.io.File)1 URISyntaxException (java.net.URISyntaxException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Produces (javax.enterprise.inject.Produces)1 Named (javax.inject.Named)1 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)1 Component (org.apache.camel.Component)1