【问题标题】:Does spring integration's tcp-inbound-channel-adapter and tcp-connection-factory have failover support?spring integration 的 tcp-inbound-channel-adapter 和 tcp-connection-factory 是否支持故障转移?
【发布时间】:2020-06-24 06:42:49
【问题描述】:

我有一个使用 spring 集成的简单 tcp 客户端,它接收消息并将其写入文件。

我希望客户端默认连接到thing.input.primary.host,但是在连接失败的情况下,我希望它重新连接到thing.input.secondary.host,然后发送消息就像普通的; Spring 集成是否支持这种行为?

编辑:为清楚起见。如果thingClient失败,我想做的是让它从thingClient切换到thingClientSecondary。

<?xml version="1.0" encoding="UTF-8"?>
<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:int-file="http://www.springframework.org/schema/integration/file"
       xmlns="http://www.springframework.org/schema/beans"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.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
            http://www.springframework.org/schema/integration/file     http://www.springframework.org/schema/integration/file/spring-integration-file.xsd">

    <int-ip:tcp-inbound-channel-adapter
            id="thingInGateway"
            connection-factory="thingClientPrimary"
            channel="fileOutputChain"
            client-mode="true"
            auto-startup="true"
            retry-interval="1000"/>

    <int-ip:tcp-connection-factory
            id="thingClientPrimary"
            type="client"
            host="${thing.input.primary.host}"
            port="${thing.input.primary.port}"
            deserializer="thingSerializer"
            serializer="thingSerializer"
            socket-support="thingSocketSupport"
            so-keep-alive="true"
            using-nio="true"/>

    <int-ip:tcp-connection-factory
            id="thingClientSecondary"
            type="client"
            host="${thing.input.secondary.host}"
            port="${thing.input.secondary.port}"
            deserializer="thingSerializer"
            serializer="thingSerializer"
            socket-support="thingSocketSupport"
            so-keep-alive="true"
            using-nio="true"/>
    <int:chain input-channel="fileOutputChain" >
        <int-file:outbound-channel-adapter directory="${thing.output.directory}"/>
    </int:chain>

</beans>

【问题讨论】:

    标签: spring spring-boot spring-integration


    【解决方案1】:

    没有;只需定义使用另一个工厂和相同通道的第二个通道适配器;那么来自任一端口的任何数据都将转到同一个地方。

    “故障转移”在服务器端是一个不寻常的术语。通常,当服务器连接丢失时,客户端会进行故障转移。

    在服务器端,我们是被动的,“故障转移”一词在这里没有意义。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多