我正在尝试使用 DSL 将应用程序中的 integration.xml 重写为 Java Config。我的集成流程是这样的:
Communication
对象来到sendCommunication
通道sendCommunication
通道被路由到两个不同的通道- 每个通道中的对象都转换为
byte[]
- 使用自定义记录器记录数据(窃听)
TcpSendingMessageHandler
来自每个通道的字节使用两个不同的 s通过 TCP 发送
这是与此流程相关的我的 Integration.java 的一部分(跳过了一些像自定义记录器这样的 bean):
@Bean(name = "sendCommunicationRouter")
public IntegrationFlow routeRoundRobin() {
return IntegrationFlows.from(getSendCommunication())
.route(roundRobinRouter, "route",
s -> s.channelMapping("sendCommunication1",
"sendCommunication1")
.channelMapping("sendCommunication2",
"sendCommunication2"))
.get();
}
@Bean(name = "sendCommunication")
public MessageChannel getSendCommunication() {
return getDefaultMessageChannel();
}
@Bean(name = "sendCommunication1")
public MessageChannel getSendCommunication1() {
return getDefaultMessageChannel();
}
@Bean(name = "sendCommunication2")
public MessageChannel getSendCommunication2() {
return getDefaultMessageChannel();
}
@Bean(name = "tcpClientOutbound1")
public TcpSendingMessageHandler getTcpClientOutbound1() {
return getDefaultTcpClientOutbound(getOutboundConnectionFactory1());
}
@Bean(name = "tcpClientOutbound2")
public TcpSendingMessageHandler getTcpClientOutbound2() {
return getDefaultTcpClientOutbound(getOutboundConnectionFactory2());
}
private TcpSendingMessageHandler getDefaultTcpClientOutbound(TcpNetClientConnectionFactory connectionFactory) {
TcpSendingMessageHandler handler = new TcpSendingMessageHandler();
handler.setConnectionFactory(connectionFactory);
handler.setTaskScheduler(myScheduler);
handler.setClientMode(true);
handler.setRetryInterval(DEFAULT_CHANNEL_RETRY_INTERVAL);
handler.start();
return handler;
}
@Bean
public IntegrationFlow handleOutgoingCommunication1() {
return handleOutgoingCommunication(getSendCommunication1(), getTcpClientOutbound1());
}
@Bean
public IntegrationFlow handleOutgoingCommunication2() {
return handleOutgoingCommunication(getSendCommunication2(), getTcpClientOutbound2());
}
private IntegrationFlow handleOutgoingCommunication(MessageChannel inputChannel, TcpSendingMessageHandler handler) {
return IntegrationFlows.from(inputChannel)
.<Communication, byte[]>transform(communication -> communicationTransformer.toBytes(communication))
.wireTap(getLogger())
.handle(handler)
.get();
}
当我尝试通过sendCommunication
通道发送数据时出现此错误(故意隐藏 IP):
2016-10-09 19:52:45 WARN TcpNetConnection:186 - 意外消息 - 没有使用连接拦截器注册的端点: IP:端口:37007:b2347dad-b65c-4686-b016-5ef5ee613bd5 - GenericMessage [payload=byte[267],标头={ip_tcp_remotePort=端口,ip_connectionId= IP:端口:37007:b2347dad-b65c-4686-b016-5ef5ee613bd5,ip_localInetAddress=/本地 IP , ip_address= IP,id=c6fb70b1-6d06-a909-cfc4-4eac7,, 时间戳=1476035565330}]
我很感激任何帮助,这个错误从昨天开始就让我头疼。我自己找不到任何解释,谷歌在 github 上只给了我这个源代码。