我想知道是否可以在spring mvc应用程序和使用TCP-IP连接的传统系统之间插入双向连接。如何在Spring MVC应用程序中插入TCP-IP客户端服务器
作为提及遗留系统与TCP/IP而不是http协作,所以不需要谈论HTTP如何更好,谢谢!
我想知道是否可以在spring mvc应用程序和使用TCP-IP连接的传统系统之间插入双向连接。如何在Spring MVC应用程序中插入TCP-IP客户端服务器
作为提及遗留系统与TCP/IP而不是http协作,所以不需要谈论HTTP如何更好,谢谢!
参见Spring Integration。您可以使用短信网关
简单地连线的SI流进你的MVC控制器控制器 - >网关 - > {可选的过滤/转换} - > TCP出站网关
网关使用其服务注入到控制器-接口。
该tcp-client-server sample显示如何。
编辑:
如果现在还不清楚从样品,你需要定义SI流...
<!-- Client side -->
<int:gateway id="gw"
service-interface="org.springframework.integration.samples.tcpclientserver.SimpleGateway"
default-request-channel="input"/>
<int-ip:tcp-connection-factory id="client"
type="client"
host="localhost"
port="1234"
single-use="true"
so-timeout="10000"/>
<int:channel id="input" />
<int-ip:tcp-outbound-gateway id="outGateway"
request-channel="input"
reply-channel="clientBytes2StringChannel"
connection-factory="client"
request-timeout="10000"
remote-timeout="10000"/>
<int:transformer id="clientBytes2String"
input-channel="clientBytes2StringChannel"
expression="new String(payload)"/>
并注入网关到您的@Controller
...
public interface SimpleGateway {
public String send(String text);
}
@Controller
public class MyController {
@Autowired
SimpleGateway gw;
...
}
我不知道答案(我对'spring'不熟悉),但'遗留系统与TCP/IP协同工作,不需要HTTP,所以不需要谈论HTTP如何更好“任何意义;他们不是竞争协议。 – admdrew
是的但在其他答案人们说http更好等 – romu31