【问题标题】:Spring Integration Header Enricher Null checkSpring Integration Header Enricher Null 检查
【发布时间】:2017-01-03 23:16:25
【问题描述】:

我的配置中有以下标题丰富器。

<int:header-enricher input-channel="" output-channel="" id="" >
    <int:header name="OrderNo" expression="@gateway.exchange(#root).payload"/> 
</int:header-enricher>

当有效负载为空时,我得到了异常

java.lang.IllegalArgumentException: payload must not be null
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.integration.support.MessageBuilder.<init>(MessageBuilder.java:56) ~[spring-integration-core-4.0.5.RELEASE.jar:na]

如果有效负载为空,有没有办法检查来自网关的空负载并在标头中设置一些虚拟值?

<int:gateway id="gateway" default-request-channel="defReqChannel" />
<int-jdbc:stored-proc-outbound-gateway request-channel="defReqChannel" data-source="dataSourceDD" expect-single-result="true" is-function="false" stored-procedure-name="SP_GET_CODE">
        <int-jdbc:sql-parameter-definition name="param1" direction="IN" />
        <int-jdbc:sql-parameter-definition name="param2" direction="IN" />
        <int-jdbc:sql-parameter-definition name="param3" direction="INOUT" />    
        <int-jdbc:sql-parameter-definition name="param4" direction="IN" /> 

        <int-jdbc:parameter name="param1" expression="exp1" />
        <int-jdbc:parameter name="param2" expression="exp2" />
        <int-jdbc:parameter name="param3" value="0"/>  
        <int-jdbc:parameter name="param4" value="0"/>
</int-jdbc:stored-proc-outbound-gateway>

我正在调用的存储过程可以返回一个空值。 (参数 3)。失败发生在这些场景中

【问题讨论】:

    标签: spring-integration


    【解决方案1】:

    请分享更多 StackTrace。 payload 不能Message 中是 null。您显示的代码完全由框架控制。

    我认为当您执行MessageBuilder.withPayload(null) 之类的操作时会有代码。

    但这完全不是你演示的配置的情况。

    更新

    这确实是一个错误:https://jira.spring.io/browse/INT-4202

    解决方法就像不使用expect-single-result="true" 并从结果Map 下游手动提取目标值。

    【讨论】:

    • 请在我的回答中找到更新
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-29
    相关资源
    最近更新 更多