我需要从spring-module.xml添加标头。我得到了低于回应
headers:
file_name: sample.txt
content_type: text/plain
Payload: { "json":{ "type":"abcd","value":"1234" }}
在标题中我需要添加另一个字段,如“time:timestamp”这些标题我们应该只从spring-module.xml添加。期待下面的标题。
headers:
file_name: sample.txt
content_type: text/plain
time:timestamp
下面的是我的spring-module.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<channel id="input"/>
<transformer input-channel="input" output-channel="output">
<beans:bean class="com.sample.PayloadValidation" >
</beans:bean>
</transformer>
<channel id="output"/>
</beans:beans>
我需要做些什么更改从spring-module.xml中添加一个更像“time”的标题..?
答案 0 :(得分:1)
请参阅Header Enricher。
<int:header-enricher input-channel="in" output-channel="out">
<int:header name="foo" value="123"/>
<int:header name="bar" ref="someBean"/>
<int:header name="baz" expression="@someBean.getHeaderValue(payload)"/>
</int:header-enricher>