Search in sources :

Example 11 with BridgeHandler

use of org.springframework.integration.handler.BridgeHandler in project spring-integration by spring-projects.

the class IntegrationFlowDefinition method route.

private <R extends AbstractMessageRouter, S extends AbstractRouterSpec<S, R>> B route(S routerSpec, Consumer<S> routerConfigurer) {
    if (routerConfigurer != null) {
        routerConfigurer.accept(routerSpec);
    }
    BridgeHandler bridgeHandler = new BridgeHandler();
    boolean registerSubflowBridge = false;
    Map<Object, String> componentsToRegister = null;
    Map<Object, String> routerComponents = routerSpec.getComponentsToRegister();
    if (routerComponents != null) {
        componentsToRegister = new LinkedHashMap<>(routerComponents);
        routerComponents.clear();
    }
    register(routerSpec, null);
    if (!CollectionUtils.isEmpty(componentsToRegister)) {
        for (Map.Entry<Object, String> entry : componentsToRegister.entrySet()) {
            Object component = entry.getKey();
            if (component instanceof IntegrationFlowDefinition) {
                IntegrationFlowDefinition<?> flowBuilder = (IntegrationFlowDefinition<?>) component;
                if (flowBuilder.isOutputChannelRequired()) {
                    registerSubflowBridge = true;
                    flowBuilder.channel(new FixedSubscriberChannel(bridgeHandler));
                }
                addComponent(flowBuilder.get());
            } else {
                this.integrationComponents.put(component, entry.getValue());
            }
        }
    }
    if (routerSpec.isDefaultToParentFlow()) {
        routerSpec.defaultOutputChannel(new FixedSubscriberChannel(bridgeHandler));
        registerSubflowBridge = true;
    }
    if (registerSubflowBridge) {
        this.currentComponent = null;
        handle(bridgeHandler);
    }
    return _this();
}
Also used : BridgeHandler(org.springframework.integration.handler.BridgeHandler) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) FixedSubscriberChannel(org.springframework.integration.channel.FixedSubscriberChannel)

Aggregations

BridgeHandler (org.springframework.integration.handler.BridgeHandler)11 SubscribableChannel (org.springframework.messaging.SubscribableChannel)5 MessageChannel (org.springframework.messaging.MessageChannel)3 Test (org.junit.Test)2 ConfigurableListableBeanFactory (org.springframework.beans.factory.config.ConfigurableListableBeanFactory)2 AbstractMessageChannel (org.springframework.integration.channel.AbstractMessageChannel)2 DirectChannel (org.springframework.integration.channel.DirectChannel)2 Message (org.springframework.messaging.Message)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 BeanFactory (org.springframework.beans.factory.BeanFactory)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 ConditionalOnProperty (org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)1 Bean (org.springframework.context.annotation.Bean)1 FixedSubscriberChannel (org.springframework.integration.channel.FixedSubscriberChannel)1 PublishSubscribeChannel (org.springframework.integration.channel.PublishSubscribeChannel)1 QueueChannel (org.springframework.integration.channel.QueueChannel)1 ReactiveStreamsSubscribableChannel (org.springframework.integration.channel.ReactiveStreamsSubscribableChannel)1