Search in sources :

Example 1 with AMQPComponent

use of org.apache.camel.component.amqp.AMQPComponent in project camel by apache.

the class AMQPComponentAutoConfiguration method configureAMQPComponent.

@Lazy
@Bean(name = "amqp-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(AMQPComponent.class)
public AMQPComponent configureAMQPComponent(CamelContext camelContext, AMQPComponentConfiguration configuration) throws Exception {
    AMQPComponent component = new AMQPComponent();
    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) AMQPComponent(org.apache.camel.component.amqp.AMQPComponent) 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 2 with AMQPComponent

use of org.apache.camel.component.amqp.AMQPComponent in project ddf by codice.

the class AmqpProducerConsumerExample method createCamelContext.

private void createCamelContext() throws Exception {
    CamelContext camelContext = getContext();
    JmsConnectionFactory connectionFactory = new JmsConnectionFactory("admin", "admin", "amqps://localhost:5671");
    JmsComponent jms = JmsComponent.jmsComponent(connectionFactory);
    AMQPComponent amqp = new AMQPComponent(connectionFactory);
    camelContext.addComponent("jms", jms);
    camelContext.addComponent("amqp", amqp);
}
Also used : CamelContext(org.apache.camel.CamelContext) JmsComponent(org.apache.camel.component.jms.JmsComponent) JmsConnectionFactory(org.apache.qpid.jms.JmsConnectionFactory) AMQPComponent(org.apache.camel.component.amqp.AMQPComponent)

Aggregations

AMQPComponent (org.apache.camel.component.amqp.AMQPComponent)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CamelContext (org.apache.camel.CamelContext)1 JmsComponent (org.apache.camel.component.jms.JmsComponent)1 JmsConnectionFactory (org.apache.qpid.jms.JmsConnectionFactory)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