Skip to content

Java DSL loses in inputChannel when existing channel is referenced by its name #9709

Closed
@artembilan

Description

@artembilan

If we have:

    @Bean
    public MessageChannel inputChannel() {
        return new DirectChannel();
    }

and use it like:

return IntegrationFlow.from("inputChannel")

Then the target IntegrationFlow does not contain a bean reference for this channel and when we call its getInputChannel() we got something from middle of the flow.
However that inputChannel is really expected to be an input for the flow.

The broken logic is in the IntegrationFlowBeanPostProcessor:

			else if (component instanceof MessageChannelReference messageChannelReference) {
				String channelBeanName = messageChannelReference.name();
				if (!this.beanFactory.containsBean(channelBeanName)) {
					DirectChannel directChannel = new DirectChannel();
					registerComponent(directChannel, channelBeanName, flowBeanName);
					targetIntegrationComponents.put(directChannel, channelBeanName);
				}
			}

So, we set channel into the targetIntegrationComponents only if bean for the provided name does not exist.

More info in SO thread: https://stackoverflow.com/questions/79248936/spring-integration-dsl-flow-to-another-flow-does-not-execute-enrichedheaders

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions