【发布时间】:2021-05-29 12:21:33
【问题描述】:
拜托,你能帮帮我吗?
所有来源都在这里。
(https://github.com/mcvzone/integration-tcp-test.git)
谢谢。
1.我创建了一个 spring integration-tcp-client 上下文 xml 文件。
<int:gateway id="gw"
service-interface="com.example.demo.module.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"
reply-timeout="10000"/>
<int:object-to-string-transformer id="clientBytes2String"
input-channel="clientBytes2StringChannel"/>
2。我创建了一个 RestController。
@RestController
public class TcpController {
final GenericXmlApplicationContext context;
final SimpleGateway simpleGateway;
public TcpController(){
this.context = new GenericXmlApplicationContext();
context.load("classpath:META-INF/spring/integration/tcpClientServerDemo-context.xml");
context.registerShutdownHook();
context.refresh();
this.simpleGateway = context.getBean(SimpleGateway.class);
}
@RequestMapping("/tcp/test")
public String test(String name) {
//SimpleGateway simpleGateway = context.getBean(SimpleGateway.class);
String result = simpleGateway.send(name);
System.out.println("result : " + result);
return result;
}
}
3.我启动 spring boot 并打开 1234 端口 (new ServerSocket(1234)) 并调用 url。(http://localhost:8080/tcp/test)
4。结果是错误。
java.lang.IllegalArgumentException: unable to determine a Message or payload parameter on method
.
.
.
at com.sun.proxy.$Proxy60.send(Unknown Source) ~[na:na]
at com.example.demo.TcpController.test(TcpController.java:25) ~[classes/:na]
【问题讨论】:
-
你能显示更多的堆栈跟踪吗?
-
同时显示
SimpleGateway代码。 -
查看我的回答并附上一些解释。
标签: spring tcp spring-integration integration