【问题标题】:Spring Integration Null correlation not allowed. Maybe the CorrelationStrategy is failing?Spring Integration 不允许空关联。也许 CorrelationStrategy 失败了?
【发布时间】:2017-09-09 04:02:29
【问题描述】:

我收到错误“不允许空关联”。也许 CorrelationStrategy 失败了?

这个论坛帖子似乎用下面的方法解决了这个问题,但是这种方法对我不起作用,http://forum.spring.io/forum/spring-projects/integration/102054-aggregator-correlation-strategy-failing

我的理解是 inbound-streaming-channel-adapter 将 FILE_NAME 作为标头值,我想加入。

    <int-ftp:inbound-streaming-channel-adapter
    auto-startup="true" id="ftpListener" channel="ftpChannel"
    session-factory="ftpSessionFactory" remote-directory="/export/home/udyj"
    filename-pattern="test1.txt">
    <integration:poller fixed-rate="5000"
        max-messages-per-poll="-1" />
</int-ftp:inbound-streaming-channel-adapter>

<int-ftp:inbound-streaming-channel-adapter
    auto-startup="true" id="ftpListener2" channel="ftpChannel"
    session-factory="ftpSessionFactory" remote-directory="/export/home/udyj"
    filename-pattern="test2.txt">
    <integration:poller fixed-rate="5000"
        max-messages-per-poll="-1" />
</int-ftp:inbound-streaming-channel-adapter>

<bean id="correlationStrategy"
    class="org.springframework.integration.aggregator.HeaderAttributeCorrelationStrategy">
    <constructor-arg value="FILE_NAME.substring(0,3)" />
</bean>
<integration:aggregator id="nuggetAggregator"
    input-channel="ftpChannel" output-channel="sendMQDistributionChannel"
    correlation-strategy="correlationStrategy">
</integration:aggregator>

【问题讨论】:

    标签: spring-integration


    【解决方案1】:

    看,你说HeaderAttributeCorrelationStrategy,绝对期望得到一个标题名称。但同时您将标题名称指定为FILE_NAME.substring(0,3),它看起来更像一个表达式。你得到 null 因为真的没有这样的标题。

    如果您想计算表达式,请考虑改用ExpressionEvaluatingCorrelationStrategy

    <bean id="correlationStrategy"
        class="org.springframework.integration.aggregator.ExpressionEvaluatingCorrelationStrategy">
        <constructor-arg value="headers.file_name.substring(0,3)" />
    </bean>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多