【问题标题】:Modifying Payload with Generated Values使用生成的值修改有效负载
【发布时间】:2016-03-15 17:13:38
【问题描述】:

我想为通过 http 入站端点传入的消息添加动态标头。 目标是在一个映射中返回 XML 有效负载以及 dnamically 生成的标头,如下所示 增强消息类。然后,EnhancedMessage 消息应该被转发到下面的 processChannel; 我尝试使用如图所示的 Header 丰富器,但我从 http 入站而不是从 消息修改了 myBean 返回的一个。这可以做到吗?我希望链中的所有端点都接收到标头。 新的 Serializable 消息应该看起来像:

    class EnhancedMessage implements Serializable{
    String getXMLRaw(){}
    Map<String,String> getHeaders(){}

}

    <int-http:inbound-channel-adapter id="dataInbound"
            supported-methods="POST" status-code-``expression="T(org.springframework.http.HttpStatus).ACCEPTED"
            path="/ops/process" channel="processChannel">
    </int-http:inbound-channel-adapter>

<int:chain input-channel="processChannel">
         <int:header-enricher>
             <ref bean="myBean"/>
        </int:header-enricher>

        <int:recipient-list-router>
            <int:recipient channel="out1" />
            <int:recipient channel="out2" />
        </int:recipient-list-router>
</int:chain>

Everything works except the message enhancement. I would appreciate any directions on how to proceed.

【问题讨论】:

    标签: spring-integration messaging


    【解决方案1】:

    Header Enricher 完全适用于 headers,它对 payload 没有任何作用。

    从一方面你可以考虑只是&lt;enricher&gt;,谁可以修改payload的部分。

    甚至是完整的&lt;transformer&gt;,它允许您完全控制消息 - 它的headerspayload

    请阅读更多Reference Manual

    【讨论】:

    • 谢谢Artem,非常感谢!
    猜你喜欢
    • 2020-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-13
    • 1970-01-01
    • 2022-11-03
    • 2012-09-18
    • 2021-04-20
    相关资源
    最近更新 更多