Skip to content

RouterSpec channelMapping takes no MessageChannel. #2754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dschulten opened this issue Feb 19, 2019 · 1 comment · Fixed by #2882
Closed

RouterSpec channelMapping takes no MessageChannel. #2754

dschulten opened this issue Feb 19, 2019 · 1 comment · Fixed by #2882

Comments

@dschulten
Copy link

Affects Version(s): 5.1.3

Enhancement

AbstractRouterSpec.defaultOutputChannel takes both a channelName and a MessageChannel.
However, RouterSpec.channelMapping only takes a channelName, but not a MessageChannel.

When using the DSL, I try to avoid explicit channel names and prefer the IntegrationFlow.getInputChannel() method to look up the input channel for a flow.

Currently I must use "mySubflow.input" for the channelMapping but I can use defaultOutputChannel(mySubFlow().getInputChannel()) for the default.

@artembilan
Copy link
Member

The current implementation fully honors a target AbstractMappingMessageRouter contract which is only based on the channel names:

void setChannelMapping(String key, String channelName);
...
void setChannelMappings(Map<String, String> channelMappings);

We can improve the RouterSpec to accept a MessageChannel as well, but you need to ensure that your channel is a NamedComponent over there. Since the target AbstractMappingMessageRouter expects from us only channel names.

As a workaround your can do something like this:

m -> m.channelMapping(true, ((NamedComponent) myFlow.getInputChannel()).getComponentName())

Feel free to raise a Pull Request with such an improvement.
We would need to check for NamedComponent in a new channelMapping() method before calling a delegate.

@artembilan artembilan self-assigned this Feb 19, 2019
@artembilan artembilan added this to the 5.2.M1 milestone Feb 19, 2019
artembilan added a commit to artembilan/spring-integration that referenced this issue Apr 4, 2019
Fixes spring-projects#2754

For better end-user experience when we have `@Bean` declared for a
channel it is good to have a `MessageChannel` based
`RouterSpec.channelMapping` for possible traceability and code
navigation in the IDE
garyrussell pushed a commit that referenced this issue Apr 5, 2019
Fixes #2754

For better end-user experience when we have `@Bean` declared for a
channel it is good to have a `MessageChannel` based
`RouterSpec.channelMapping` for possible traceability and code
navigation in the IDE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants