Search in sources :

Example 1 with Sjms2Component

use of org.apache.camel.component.sjms2.Sjms2Component in project camel by apache.

the class Jms2TestSupport method createCamelContext.

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

Example 2 with Sjms2Component

use of org.apache.camel.component.sjms2.Sjms2Component in project camel by apache.

the class Sjms2ComponentAutoConfiguration method configureSjms2Component.

@Lazy
@Bean(name = "sjms2-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(Sjms2Component.class)
public Sjms2Component configureSjms2Component(CamelContext camelContext, Sjms2ComponentConfiguration configuration) throws Exception {
    Sjms2Component component = new Sjms2Component();
    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) Sjms2Component(org.apache.camel.component.sjms2.Sjms2Component) 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 3 with Sjms2Component

use of org.apache.camel.component.sjms2.Sjms2Component 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)

Aggregations

Sjms2Component (org.apache.camel.component.sjms2.Sjms2Component)3 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)2 CamelContext (org.apache.camel.CamelContext)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConnectionFactory (javax.jms.ConnectionFactory)1 ConnectionFactoryResource (org.apache.camel.component.sjms.jms.ConnectionFactoryResource)1 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)1 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)1 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1 Lazy (org.springframework.context.annotation.Lazy)1