2017-02-15 13 views
0

spring-module.xmlからヘッダーを追加する必要があります。我々は唯一の春-module.xmlから追加する必要がありますこれらのヘッダー:私は、応答の下に、私は「タイムスタンプの時間」のように別のフィールドを追加する必要がヘッダーでspring-module.xmlから新しいヘッダーを追加する方法

headers:  
file_name: sample.txt 
content_type: text/plain 

Payload: { "json":{ "type":"abcd","value":"1234" }} 

を取得しています。次のようなヘッダーが必要です。以下

headers:  
file_name: sample.txt 
content_type: text/plain 
time:timestamp 

私の春-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> 

私は春-module.xmlから「時間」のような1つの以上のヘッダを追加行うために必要な変更は何ですか..?

答えて

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> 
+0

はい、ありがとうございます。これに基づいて私はヘッダーを追加することができます。もう一度ありがとう。 –

関連する問題