I'm using
- spring-integration-java-dsl-1.2.3.RELEASE
- spring-integration-ip-4.3.17.RELEASE
- spring-integration-http-4.3.17.RELEASE
Given this code to generate dynamically TCP connections. I define the ReveiverAdapter and SenderAdapter.
IntegrationFlow ifr = existsConnection(connectionId);
if (ifr == null) {
TcpNetClientConnectionFactory cf = new TcpNetClientConnectionFactory(host, port);
final ByteArrayLengthHeaderSerializer by = new ByteArrayLengthHeaderSerializer(headBytes);
cf.setSingleUse(false);
cf.setSoKeepAlive(true);
cf.setSerializer(by);
cf.setDeserializer(by);
cf.setComponentName(connectionId);
//Inbound Adapter
TcpReceivingChannelAdapter adapter = new TcpReceivingChannelAdapter();
adapter.setConnectionFactory(cf);
adapter.setClientMode(true);
adapter.setErrorChannelName("errorChannel");
adapter.setRetryInterval(retryInterval);
adapter.setOutputChannel(bme.fromTcp());
//OutBound Adapter
TcpSendingMessageHandler sender = new TcpSendingMessageHandler();
sender.setConnectionFactory(cf);
ifr = IntegrationFlows.from(adapter)
.enrichHeaders(h -> h.header("connectionId",connectionId))
.handle(sender).get();
this.flowContext.registration(ifr).id(connectionId+CONNECTION_SUFFIX).addBean(cf).register();
When I try to reroute to the correct channel the first time I run it I get "fromTcp" instead of the sender adapter, when I recover the channel from IntegrationFlow.getInputChannel()