Expose session limitation on remote file adapters

  Deprecate 'cache-sessions' attribute

  Add 'sessionCacheSize' and 'sessionWaitTimeout' attributes on CachingSessionFactory

  Update documentation
This commit is contained in:
Oleg Zhurakousky
2011-10-14 14:31:57 -04:00
committed by Mark Fisher
parent 761a797ee1
commit 7f92089584
10 changed files with 292 additions and 97 deletions

View File

@@ -346,17 +346,35 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/ftp
<section id="ftp-session-caching">
<title>FTP Session Caching</title>
<para>
One of the optimizations implemented by the FTP adapters is session caching. Similar to JDBC pooling of Connections, the FTP Adapters maintain a
pool of Sessions by default. However there are times when this behavior is not desired (e.g., security etc.).
To disable session caching you can set the <code>cache-sessions</code> attribute to <code>false</code> (the default value is <code>true</code>).
<programlisting language="xml"><![CDATA[<int-ftp:inbound-channel-adapter id="ftpInbound"
channel="ftpChannel"
. . .
cache-sessions="false"
. . .
</int-ftp:inbound-channel-adapter>]]></programlisting>
Since version 2.1 we've exposed more flexibility with regard to session management for remote file adapters (e.g., FTP, SFTP etc).
In previous versions the sessions were cached automatically. And although we did expose <code>cache-session</code> attribute which would
allow you to turn auto caching off it was still not sufficient when it came to other session caching attributes.
For example; One of the requirement we received was to control session limit if remote server imposes client connection limit.
Now such behavior is controlled by the <classname>CachingSessionFactory</classname> and its <code>sessionCacheSize</code> and
<code>sessionWaitTimeout</code> properties. As its name suggest <code>sessionCacheSize</code> property controls how many active
sessions this adapter will maintain in its cache (DEFAULT unbounded). If <code>sessionCacheSize</code> threshold has been reached any
attempt to get more session will block until session becomes available or until wait time for a session to become available
expires (DEFAULT Integer.MAX_VALUE). The wait time for a session to become available can also be controlled via <code>sessionWaitTimeout</code>
property.
</para>
<para>
Since version 2.1 if you need you session to be cahced you can simply configure your default Session Factory as
described above and than wrap it in the <classname>CachingSessionFactory</classname> while providing additional properties.
<programlisting language="xml"><![CDATA[<bean id="ftpSessionFactory" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
<property name="host" value="localhost"/>
</bean>
<bean id="cachingSessionFactory" class="org.springframework.integration.file.remote.session.CachingSessionFactory">
<constructor-arg ref="ftpSessionFactory"/>
<constructor-arg value="10"/>
<property name="sessionWaitTimeout" value="1000"/>
</bean>]]></programlisting>
In the above example you see <classname>CachingSessionFactory</classname> created with
<code>sessionCacheSize</code> set to 10 with <code>sessionWait</code> timeout set to 1 second.
The same attribute can also be used with Outbound Channel Adapters.
</para>
</section>
</chapter>

View File

@@ -290,17 +290,34 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/sftp
<section id="sftp-session-caching">
<title>SFTP Session Caching</title>
<para>
One of the optimizations implemented by the SFTP adapters is session caching. Similar to JDBC pooling of Connections, the SFTP Adapters maintain a
pool of Sessions by default. However there are times when this behavior is not desired (e.g., security etc.).
To disable session caching you can set the <code>cache-sessions</code> attribute to <code>false</code> (the default value is <code>true</code>).
<programlisting language="xml"><![CDATA[<int-sftp:inbound-channel-adapter id="ftpInbound"
channel="sftpChannel"
. . .
cache-sessions="false"
. . .
</int-sftp:inbound-channel-adapter>]]></programlisting>
Since version 2.1 we've exposed more flexibility with regard to session management for remote file adapters (e.g., FTP, SFTP etc).
In previous versions the sessions were cached automatically. And although we did expose <code>cache-session</code> attribute which would
allow you to turn auto caching off it was still not sufficient when it came to other session caching attributes.
For example; One of the requirement we received was to control session limit if remote server imposes client connection limit.
Now such behavior is controlled by the <classname>CachingSessionFactory</classname> and its <code>sessionCacheSize</code> and
<code>sessionWaitTimeout</code> properties. As its name suggest <code>sessionCacheSize</code> property controls how many active
sessions this adapter will maintain in its cache (DEFAULT unbounded). If <code>sessionCacheSize</code> threshold has been reached any
attempt to get more session will block until session becomes available or until wait time for a session to become available
expires (DEFAULT Integer.MAX_VALUE). The wait time for a session to become available can also be controlled via <code>sessionWaitTimeout</code>
property.
</para>
<para>
Since version 2.1 if you need you session to be cahced you can simply configure your default Session Factory as
described above and than wrap it in the <classname>CachingSessionFactory</classname> while providing additional properties.
<programlisting language="xml"><![CDATA[<bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<property name="host" value="localhost"/>
</bean>
<bean id="cachingSessionFactory" class="org.springframework.integration.file.remote.session.CachingSessionFactory">
<constructor-arg ref="sftpSessionFactory"/>
<property name="sessionCacheSize" value="10"/>
<property name="sessionWaitTimeout" value="1000"/>
</bean>]]></programlisting>
In the above example you see <classname>CachingSessionFactory</classname> created with
<code>sessionCacheSize</code> set to 10 with <code>sessionWait</code> timeout set to 1 second.
The same attribute can also be used with Outbound Channel Adapters.
</para>
</section>
</chapter>