0

外部サービスとの対話に tcp 接続を使用する SOAP サービスがあります。この tcp サービスに接続プールを使用しています。アプリを起動して最初の SOAP リクエストを送信すると、すべて正常に動作しますが、1 分待つと、応答が得られません。しかし、Wireshark でトラフィックを盗聴すると、どのような応答が返されるかがわかります。そして、少し追加-1分待たずに新しいリクエストを送信した場合-すべて正常に機能します。問題が発生するのは、1 分間待機した場合のみです。これは、プールと tcp の構成です。

<beans profile="single">
    <bean id="testConnectionFactory" class="com.test.provider.impl.ProviderTcpConnectionFactory">
        <constructor-arg name="host" value="localhost"/>
        <constructor-arg name="port" value="7700"/>
        <property name="connectionTimeout" value="10000"/>
        <property name="soTimeout" value="60000"/>
        <property name="deserializer" ref="testDeserializer"/>
        <property name="singleUse" value="true"/>
    </bean>
</beans>

<beans profile="pool">
    <bean id="testConnection" class="com.test.provider.impl.ProviderTcpConnectionFactory">
        <constructor-arg name="host" value="localhost"/>
        <constructor-arg name="port" value="7700"/>
        <property name="connectionTimeout" value="10000"/>
        <property name="soTimeout" value="60000"/>
        <property name="deserializer" ref="testDeserializer"/>
        <property name="singleUse" value="true"/>
    </bean>
    <bean id="testConnectionFactory" class="org.springframework.integration.ip.tcp.connection.CachingClientConnectionFactory">
        <constructor-arg ref="testConnection"/>
        <constructor-arg value="5"/>
    </bean>
</beans>

ログに次の行が表示されます

DEBUG [org.springframework.integration.ip.tcp.connection.TcpNetConnection] Closed single use socket after timeout

私が理解しているように、ソケットは soTimeout の有効期限が切れた後に閉じられました。しかし、接続を閉じずにプールを使用する方法は?

4

1 に答える 1

1

This is a bug in the CachingClientConnectioNFactory; it doesn't properly handle connections that time out in this way; the connection is not actually closed and the reader thread is terminated.

Please open a JIRA Issue; thanks.

A work around might be to remove the soTimeout attribute; you could also put an soTimeout on the server side so it initiates the close.

Actually, given that you are using single-use="true" (a new socket for each connection), you will get no benefit from using the CachingClientConnectionFactory; it's intended to provide a pool of shared connections.

于 2013-09-21T19:14:09.150 に答える