spring integration

spring integration http 根据http的get和post请求 走不同的流程


<int-http:inbound-gateway request-channel="receiveChannel"
                          name="/receiveGateway"
                          supported-methods="GET,POST"
                          mapped-request-headers="Content-Type,user-agent,host,outbound"
                              mapped-response-headers="Content-Type"/>
<int:channel id="receiveChannel"/>
<bean id="myTestBean" class="org.springframework.integration.samples.test.Mytest"/>
<!-- 路由器    根据message的header 进行区分-->
<int:header-value-router input-channel="receiveChannel"
                             header-name="http_requestMethod"
                             resolution-required="false">
        <!-- 路由GET 和 POST请求 -->
        <int:mapping value="GET" channel="getRequestChannel"/>
        <int:mapping value="POST" channel="postRequestChannel"/>
    </int:header-value-router>
<!-- 定义处理get请求的channel -->
<int:channel id="getRequestChannel"></int:channel>
<int:service-activator input-channel="getRequestChannel" method="myTest" ref="myTestBean"
output-channel="endChannel" />
<!-- 定义处理post请求的channel -->
<int:channel id="postRequestChannel"></int:channel>
<int:service-activator input-channel="postRequestChannel" method="myTest2" ref="myTestBean"
output-channel="endChannel"/>
<!--  处理结束  返回的channel -->
<int:channel id="endChannel" />
<int:service-activator input-channel="endChannel" expression="payload + 'return from second mehond'"/>


猜你喜欢

转载自zi-hao.iteye.com/blog/1979383