Announcement Announcement Module
Collapse
No announcement yet.
Change SftpSessionFactory at Runtime Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Change SftpSessionFactory at Runtime

    Hi forum,

    I am struggling with the following use case scenario:

    My application is writing some files into a remote directory with a stfp outbound adapter. So far so good. Everything is allright.
    Depending on a parameter within the payload of a message I should be able to change the remote host on the fly during runtime. So the difficulty is, how to alter the sftp outbound adapter that it is not using one standard SftpSessionFactory at a time, instead using a maybe-called MySftpSessionFactorySelecter as the way to get the session from a centralized configuration bean that holds all necessary SessionFactories.

    I found an interesting thread here in the forum:
    http://forum.springsource.org/showth...e-destinations
    but the author is referring to the following issue https://jira.springsource.org/browse/INT-1945 which should solve the problem. But I can't see how the sftp outbound gateway should get me out of this?

    I tried to extend FileTransferringMessageHandler and DefaultSftpSession but with little or no luck at all.
    I know that I could go on and configure different channels with different outbound adapters using some routing mechanism but I want to do it in a generic way because the piece of software is used in a high scalable environment where it would be extremly cumbersome to configure all the different remote hosts by hand.

    Maybe someone is able to give me some hints or directions where to go from here.

    Thx in advance for your help guys!
    Cheers Peter
    Last edited by peter0601; Mar 8th, 2013, 08:12 AM.

  • #2
    See the dynamic ftp sample - it shows how to create outbound adapters on-demand...

    https://github.com/SpringSource/spri...ed/dynamic-ftp

    Also, see this thread http://forum.springsource.org/showth...696#post418696

    Comment


    • #3
      Hi Gary,

      I am getting used to the fact that you save my weekends... ;-)
      Thx for the hint, i will give it a try and let you know if I am successfull.

      Thx

      Comment


      • #4
        Hi together,

        just for completion of the thread. Gary's hint guided me the right path.
        I was able to successfully switch SessionFactory at Runtime. Just create a new ApplicationContext with the channels.
        Be careful at setting the environment variables if you are using the example code within a web application. The username was overritten by the system environment so I wasn't able to create a valid ssh session to the remote host. But after solving this issue everything works like a charm.

        Thx again for the incredible fast and high-quality answer in the forum.
        I guess I will be back soon
        Peter

        Comment

        Working...
        X