fmdaboville
fmdaboville

Reputation: 1831

Produce MessageSource using TCP with Spring integration

What is the best way to produce MessageSource in Spring Integration wih a TCP client, which is receiving some data from a server ? My app is already wotking with data from FTP and SFTP, but I need to implements a version with TCP. In previous versions, the entry point was an InboundChannelAdapter like this :

@Bean
@InboundChannelAdapter(value = "channel", poller = @Poller(fixedDelay = "10000", maxMessagesPerPoll = "-1"))
public MessageSource<File> ftpMessageSource(
        @Autowired AbstractInboundFileSynchronizer<FTPFile> ftpInboundFileSynchronizer) {
    FtpInboundFileSynchronizingMessageSource source = new FtpInboundFileSynchronizingMessageSource(
            ftpInboundFileSynchronizer);
    source.setLocalDirectory(new File(repo));
    source.setAutoCreateLocalDirectory(true);
    source.setLocalFilter(new AcceptAllFileListFilter<File>());
    return source;
}

Upvotes: 0

Views: 148

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121550

There is no MessageSource for the TCP. Just because TCP/IP is a streaming protocol so we have there continuously working listener via MessageProducer implementation - TcpReceivingChannelAdapter. There is just need to declare plain @Bean definition for this one and use the proper ConnectionFactory and MessageChannel for injection.

Upvotes: 1

Related Questions