org.apache.camel.component.amqp.AMQPComponent Java Examples

The following examples show how to use org.apache.camel.component.amqp.AMQPComponent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AMQPComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "amqp-component")
@ConditionalOnMissingBean(AMQPComponent.class)
public AMQPComponent configureAMQPComponent() throws Exception {
    AMQPComponent component = new AMQPComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<AMQPComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.amqp.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.amqp.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #2
Source File: TransactionApplication.java    From eda-tutorial with Apache License 2.0 5 votes vote down vote up
@Bean
public AMQPComponent amqps(EnmasseProperties enmasseProperties) {
    AMQPComponent amqpComponent = new AMQPComponent();
    amqpComponent.setConfiguration(new JmsConfiguration(
            new CachingConnectionFactory(new JmsConnectionFactory(enmasseProperties.toJmsRemoteURI()))
    ));
    return amqpComponent;
}
 
Example #3
Source File: AccountApplication.java    From eda-tutorial with Apache License 2.0 5 votes vote down vote up
@Bean
public AMQPComponent amqps(EnmasseProperties enmasseProperties) {
    AMQPComponent amqpComponent = new AMQPComponent();
    amqpComponent.setConfiguration(new JmsConfiguration(
            new CachingConnectionFactory(new JmsConnectionFactory(enmasseProperties.toJmsRemoteURI()))
    ));
    return amqpComponent;
}
 
Example #4
Source File: EnmasseSenderApplication.java    From eda-tutorial with Apache License 2.0 5 votes vote down vote up
@Bean
public AMQPComponent amqps(EnmasseProperties enmasseProperties) {
    AMQPComponent amqpComponent = new AMQPComponent();
    amqpComponent.setConfiguration(new JmsConfiguration(
            new CachingConnectionFactory(new JmsConnectionFactory(enmasseProperties.toJmsRemoteURI()))
    ));
    return amqpComponent;
}
 
Example #5
Source File: EnmasseReceiverApplication.java    From eda-tutorial with Apache License 2.0 5 votes vote down vote up
@Bean
public AMQPComponent amqps(EnmasseProperties enmasseProperties) {
    AMQPComponent amqpComponent = new AMQPComponent();
    amqpComponent.setConfiguration(new JmsConfiguration(
            new CachingConnectionFactory(new JmsConnectionFactory(enmasseProperties.toJmsRemoteURI()))
    ));
    return amqpComponent;
}
 
Example #6
Source File: AMQPConnector.java    From syndesis with Apache License 2.0 4 votes vote down vote up
private AMQPComponent lookupComponent() {
    final CamelContext context = getCamelContext();
    final List<String> names = context.getComponentNames();

    if (ObjectHelper.isEmpty(names)) {
        return null;
    }

    // lookup existing component with same configuration
    for (String name: names) {

        Component cmp = context.getComponent(name, false, false);
        if (cmp instanceof AMQPComponent) {

            final ConnectionFactory factory;
            try {
                factory = ((AMQPComponent)cmp).getConfiguration().getConnectionFactory();
            } catch (IllegalArgumentException e) {
                // ignore components without a connection factory
                continue;
            }

            if (factory instanceof JmsConnectionFactory) {
                JmsConnectionFactory jmsConnectionFactory = (JmsConnectionFactory)factory;

                if (!Objects.equals(connectionUri, jmsConnectionFactory.getRemoteURI())) {
                    continue;
                }
                if (!Objects.equals(username, jmsConnectionFactory.getUsername())) {
                    continue;
                }
                if (!Objects.equals(password, jmsConnectionFactory.getPassword())) {
                    continue;
                }
                if (!Objects.equals(clientId, jmsConnectionFactory.getClientID())) {
                    continue;
                }

                return (AMQPComponent) cmp;
            }
        }
    }

    return null;
}