如何处理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