I've been trying to create a consumer and a producer using the Spring Integration TCP. I've achived some success on the listening part (I got the message sended by a telnet normally), but when I try to send this same message to the terminal client, nothing happens.
These are my classes:
@EnableIntegration
@IntegrationComponentScan
@Configuration
public class TcpIntegration {
@Value("${tcp.port}")
private Integer port;
@MessagingGateway(defaultRequestChannel="toTcp")
public interface Gateway {
String viaTcp(String in);
}
@Bean
@ServiceActivator(inputChannel="toTcp")
public TcpSendingMessageHandler tcpOutGate(AbstractClientConnectionFactory connectionFactory) {
TcpSendingMessageHandler gate = new TcpSendingMessageHandler();
gate.setConnectionFactory(connectionFactory);
return gate;
}
@Bean
public TcpReceivingChannelAdapter tcpInGate(AbstractServerConnectionFactory connectionFactory) {
TcpReceivingChannelAdapter inGate = new TcpReceivingChannelAdapter();
inGate.setConnectionFactory(connectionFactory);
inGate.setOutputChannel(fromTcp());
return inGate;
}
@Bean
public MessageChannel fromTcp() {
return new DirectChannel();
}
@Bean
public AbstractClientConnectionFactory clientCF() {
return new TcpNetClientConnectionFactory("localhost", this.port);
}
@Bean
public AbstractServerConnectionFactory serverCF() {
return new TcpNetServerConnectionFactory(this.port);
}
}
TcpListener
@MessageEndpoint
@AllArgsConstructor
public class TcpListener {
private final Gateway gateway;
@ServiceActivator(inputChannel = "fromTcp")
public void convert(String payload) {
System.out.println(payload);
gateway.viaTcp(payload);
}
}
Why doesn't it work?