我有两个int-http:inbound-gateway with path,如下所述。并且指向相同的请求通道但具有不同的回复通道。
http://localhost:8080/XYZ/ABCService/query -- i expected to call http:inbound-gateway with id ="XYZ"
http://localhost:8080/ABCService/query - i expected to call http:inbound-gateway with id ="default"
但是当我向
提出请求时,它的不一致性是什么 http://localhost:8080/XYZ/ABCService/query
它正在呼叫"默认"网关其他时间它的呼叫" XYZ"即不一致。或者不确定它是否可以正确调用,而是响应不同的回复频道?
我正在使用DispatcherServlet.Below我的spring-integration.xml
<int-http:inbound-gateway id="default"
path="/*Service/query"
request-channel="RequestChannel" reply-channel="ResponseChannel"
supported-methods="POST" reply-timeout="5000" request-payload-type="java.lang.String"
error-channel="ErrorChannel" mapped-request-headers="xyz-*, HTTP_REQUEST_HEADERS">
<int-http:header name="reply-type" expression="'DEFAULT'" />
</int-http:inbound-gateway>
<int-http:inbound-gateway id="XYZ"
path="/XYZ/*Service/query"
request-channel="RequestChannel" reply-channel="XYZExportTransformedChannel"
supported-methods="POST" reply-timeout="5000" request-payload-type="java.lang.String"
error-channel="ErrorChannel" mapped-request-headers="xyz-*, HTTP_REQUEST_HEADERS">
<int-http:header name="reply-type" expression="'ABC'" />
</int-http:inbound-gateway>
<!--All endpoints output chanlle is CommonResonseChannel -->
<int:channel id="CommonResponseChannel">
</int:channel>
<!-- final router -->
<int:header-value-router input-channel="CommonResponseChannel"
header-name="reply-type">
<int:mapping value="DEFAULT" channel="ResponseChannel" />
<int:mapping value="ABC" channel="XYZResponseChannel" />
</int:header-value-router>
<int:channel id="ResponseChannel">
</int:channel>
<int:channel id="XYZResponseChannel">
</int:channel>
<int:transformer input-channel="XYZResponseChannel"
output-channel="XYZExportTransformedChannel" id="TransformerChannel"
ref="objToCSVTransformer"></int:transformer>
<bean class="SomeTransformer"
id="objToCSVTransformer"></bean>
<int:channel id="XYZExportTransformedChannel" />
I have opened this question before not not very clear.Not sure how to update that.So opened new one.
答案 0 :(得分:0)
您不应该以这种方式配置回复频道;它可能会导致不可预测的结果。
reply-channel
只是桥接到消息replyChannel
标题,因此它通常可以正常工作,但它是不可预测的,因为在网关首次收到消息时设置了网桥。
相反,只需省略网关上的reply-channel
属性,让框架使用replyChannel
标题直接路由回复。
而不是路由器,配置“无处可通”(<bridge/>
input-channel= CommonResponseChannel"
而不是output-channel
。
或者只是省略最后一个端点上的output-channel
(而不是发送到CommonResponseChannel
)。