I wonder if it is possible to plug a bidirectional connection between a spring mvc application and a legacy system working with TCP-IP connections.
as mentionned the legacy system works with TCP/ip and not http , so no need to talk about how HTTP is better , thanks !
See Spring Integration. You can simply wire an SI flow into your MVC controller using a messaging gateway
Controller->gateway->{optional filtering/transforming}->tcp outbound gateway
The gateway is injected into the controller using its service-interface.
The tcp-client-server sample shows how.
EDIT:
If it's not clear from the sample, you would need to define your SI flow...
<!-- 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)"/>
and inject the Gateway into your @Controller
...
public interface SimpleGateway {
public String send(String text);
}
@Controller
public class MyController {
@Autowired
SimpleGateway gw;
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With