Announcement Announcement Module
Collapse
No announcement yet.
STS 2.9.0 Int Project Template - File, default-output-channel in header-value-router Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • STS 2.9.0 Int Project Template - File, default-output-channel in header-value-router

    Hello:

    The new release of the SpringSource Tool Suite (2.9.0) comes with three new templates for Spring integration projects.

    I'm working with them in order to quickly learn Spring integration.

    And I spent a lot in the "header-value-router" from the Spring integration Project (standalone) - File:

    Code:
        <!-- See also:
            http://static.springsource.org/spring-integration/reference/htmlsingle/#router
            http://www.eaipatterns.com/MessageRouter.html -->
        <int:header-value-router id="fileTypeRouter"
                            header-name="file_extension"
                            input-channel="routingChannel"
                            default-output-channel="otherFilesOut">
            <int:mapping value="csv" channel="csvFilesOut"/>
            <int:mapping value="xml" channel="xmlFilesOut"/>
        </int:header-value-router>
    Since it's my first try with Spring Integration, I expected (from HeaderValueRouter in 5.1.3 Router Implementations):

    Normally, messages for which the header value is not explicitly mapped to a channel will be sent to the default-output-channel.
    And I found logical:

    However, in cases where the header value is mapped to a channel name but the channel cannot be resolved, setting the resolution-required attribute to false will result in routing such messages to the default-output-channel.
    But it was a surprise to me to discover after several exceptions that:

    Attribute resolution-required will default to true.
    So, this little change works for me:

    Code:
        <!-- See also:
            http://static.springsource.org/spring-integration/reference/htmlsingle/#router
            http://www.eaipatterns.com/MessageRouter.html -->
        <int:header-value-router id="fileTypeRouter"
                            header-name="file_extension"
                            input-channel="routingChannel"
                            default-output-channel="otherFilesOut"
                            resolution-required="false">
            <int:mapping value="csv" channel="csvFilesOut"/>
            <int:mapping value="xml" channel="xmlFilesOut"/>
        </int:header-value-router>
    Greetings.

  • #2
    Hi,

    Thanks for point out this issue. I have created the following Jira: https://jira.springsource.org/browse/INTTEMPLATES-2

    My apologies for this issue - The templates were originally targeting Spring Integration 2.0 and this issue slipped through with the 2.1 release.

    With Spring Integration 2.1 the router configuration was refactored - the "ignore-channel-name-resolution-failures" attribute was removed in favor of consolidating its behavior with the "resolution-required" attribute. Also, the "resolution-required" attribute now defaults to true. Thus, channel resolution is now much more explicit, meaning that when a channel cannot be resolved, it is not by default sent to the default output channel but the user has to set 'resolution-required="false"' in order to enable that behavior.

    The template does not reflect that change for 2.1. I will try to resolve the Jira later tonight, adding:

    Code:
    resolution-required="false"
    Cheers,

    Gunnar

    Comment


    • #3
      Thank you very much for kindly taking into account my comments.

      Regarding the default behaviour, maybe more people will do the same assumption when they see a default channel (specially if they don't read the documentation. I made that mistake)

      Comment

      Working...
      X