![](/img/trans.png)
[英]Spring Integration (HTTP in/outbound gateway) Vs Spring Data REST
[英]http outbound gateway httpstatuscodeexception
如果http出站網關拋出httpstatuscodeexception ...,它將冒泡到我調用網關方法的地方。 我似乎無法在那兒捕捉到異常
我有以下配置
<int:channel id="responseChannel" />
<int:gateway id="someGateway" service-interface="someinterface" default-request-channel="requestChannel" default-reply-channel="responseChannel" default-reply-timeout="${reply.timeout}">
<int:method name ="somemethod">
</int:gateway>
<int:chain id="some-gateway-chain" input-channel="requestChannel" output- channel="responseChannel">
<int:object-to-json-transformer />
<int-http:outbound-gateway url-expression="some url" http-method="POST" expected-response-type-expression="some.RESPONSE_TYPE" request-factory="somehttpClientFactory" reply-timeout="${reply.timeout}"/>
</int:chain>
編輯:------------------------------------------------ -------
我可以做下面的事情嗎
<int:service-activator input-channel="errorChannel" output-channel="some other channel">
<int-groovy:script> how do i check if the payload.message.cause is a httpstatuscodeexception and then throw it from here
</int-groovy:script> </int:service-activator>
將error-channel
添加到<int:gateway/>
並在那里處理異常。 錯誤通道上的消息是一個ErrorMessage
,其有效負載為MessagingException
,其屬性為failedMessage
和cause
。
錯誤流可以引發另一個異常或返回其他結果。
回應您的編輯 :
呃...
if (payload.cause instanceof ...) {
throw payload.cause
}
someOtherResult
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.