我的应用程序使用Spring集成与第三方系统进行通信。我发送一个有效载荷,对此,我得到了解析和使用的响应。都好。请在下面使用我使用的SI xml。
现在,我想在异常情况下(尝试连接的服务器不可用,超时或拒绝连接等)重新尝试建立连接。 如何使用SI xml配置实现此目标?请指导。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-ip="http://www.springframework.org/schema/integration/ip"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/ip http://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd">
<int:gateway id="gw" service-interface=" com.RxGateway"
default-request-channel="objectOut" />
<int:channel id="objectOut" />
<int-ip:tcp-connection-factory id="client"
type="client" host="10.236.249.xx" port="9103" single-use="false"
so-timeout="50000000" using-nio="false" so-keep-alive="true"
serializer="customDSerializer" deserializer="customDSerializer" />
<bean id="customDSerializer" class="com.CustomSerializerDeserializer">
<property name="maxMessageSize" value="4096" />
</bean>
<int-ip:tcp-outbound-gateway id="outGateway"
request-channel="objectOut" reply-channel="toSA" connection-factory="client"
request-timeout="100000" reply-timeout="50000"/>
<int:service-activator input-channel="toSA"
ref="rxService" method="parseResponse"/>
<bean id="rxService" class="com.RxService"/>
<int:channel id="toSA" />
<int:channel id="bytesIn" />
</beans>
答案 0 :(得分:1)
您可以将retry-advice
添加到您的<int-ip:tcp-outbound-gateway>
中:
<int-ip:tcp-outbound-gateway>
<int-ip:request-handler-advice-chain>
<int:retry-advice/>
</int-ip:request-handler-advice-chain>
</int-ip:tcp-outbound-gateway>
请参阅参考手册中的更多信息:https://docs.spring.io/spring-integration/docs/current/reference/html/#message-handler-advice-chain