For the latest stable version, please use Spring Integration 6.4.0!spring-doc.cn

Delegating Session Factory

Version 4.2 introduced the DelegatingSessionFactory, which allows the selection of the actual session factory at runtime. Prior to invoking the FTP endpoint, call setThreadKey() on the factory to associate a key with the current thread. That key is then used to look up the actual session factory to be used. You can clear the key by calling clearThreadKey() after use.spring-doc.cn

See Context Holder Advice for more information how this factory can be used together with a ContextHolderRequestHandlerAdvice.spring-doc.cn

When you use session caching (see FTP Session Caching), each of the delegates should be cached. You cannot cache the DelegatingSessionFactory itself.

Starting with version 5.0.7, the DelegatingSessionFactory can be used in conjunction with a RotatingServerAdvice to poll multiple servers; see Inbound Channel Adapters: Polling Multiple Servers and Directories.spring-doc.cn