如何處理HTTP出站網關中的異常? 當我收到狀態代碼500或400 ...時,顯示一個例外。那麼我應該怎麼做來處理使用spring集成的http錯誤。彈簧集成:處理HTTP錯誤與oubound網關
我的配置是這樣的:
<int:inbound-channel-adapter channel="quakeinfotrigger.channel"
expression="''">
<int:poller fixed-delay="60000"></int:poller>
</int:inbound-channel-adapter>
<int:channel id="quakeinfo.channel">
<int:queue capacity="10" />
</int:channel>
<int:channel id="quakeinfotrigger.channel"></int:channel>
<int:channel id="error.channel">
<int:queue capacity="10" />
</int:channel>
<int:service-activator input-channel="error.channel"
ref="httpResponseErrorHandler" method="handleMessage">
<int:poller fixed-delay="5000"></int:poller>
</int:service-activator>
<int:service-activator input-channel="quakeinfo.channel"
ref="httpResponseMessageHandler" method="handleMessage">
<int:poller fixed-delay="5000"></int:poller>
</int:service-activator>
<int:gateway id="requestGateway" service-interface="standalone.HttpRequestGateway"
default-request-channel="quakeinfotrigger.channel" error-channel="error.channel" />
<int-http:outbound-gateway id="quakerHttpGateway"
request-channel="quakeinfotrigger.channel" url="http://fooo/mmmm/rest/put/44545454"
http-method="PUT" expected-response-type="java.lang.String" charset="UTF-8"
reply-timeout="5000" reply-channel="quakeinfo.channel">
</int-http:outbound-gateway>
<bean id="httpResponseMessageHandler" class="standalone.HttpResponseMessageHandler" />
<bean id="httpResponseErrorHandler" class="standalone.HttpResponseErrorHandler" />
我想知道爲什麼例外一點兒也不去回覆道
錯誤通道已經加入到網關,但總是一個HttpServerErrorException被拋出,我的配置文件被更新 – NAZEHA
因爲你沒有使用網關;入站適配器直接發送到'quakeinfotrigger.channel'。您也可以在入站適配器的輪詢器中添加一個「錯誤通道」;那麼你根本就不需要網關。 –
謝謝你加里。有用 !!! – NAZEHA