You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/FailoverClientConnectionFactory.java
Copy file name to clipboardExpand all lines: src/reference/asciidoc/ip.adoc
+7-5
Original file line number
Diff line number
Diff line change
@@ -536,23 +536,25 @@ The following example shows how to configure a failover client connection factor
536
536
537
537
NOTE: When using the failover connection factory, the `singleUse` property must be consistent between the factory itself and the list of factories it is configured to use.
538
538
539
-
The connection factory has two properties when used with a shared connection (`singleUse=false`):
539
+
The connection factory has two properties related to failing back, when used with a shared connection (`singleUse=false`):
540
540
541
541
* `refreshSharedInterval`
542
542
* `closeOnRefresh`
543
543
544
-
These are `0` and `false` to retain the same behavior that existed before the properties were added.
545
-
546
544
Consider the following scenario based on the above configuration:
547
545
Let's say `clientFactory1` cannot establish a connection but `clientFactory2` can.
548
-
Each time the `failCF` `getConnection()` method is called, we will again attempt to connect using `clientFactory1`; if successful, the "old" connection will remain open and may be reused in future if the first factory fails once more.
546
+
When the `failCF` `getConnection()` method is called after the `refreshSharedInterval` has passed, we will again attempt to connect using `clientFactory1`; if successful, the connection to `clientFactory2` will be closed.
547
+
If `closeOnRefresh` is `false`, the "old" connection will remain open and may be reused in future if the first factory fails once more.
549
548
550
-
Set `refreshSharedInterval` to only attempt to reconnect with the first factory after that time has expired; set it to `Long.MAX_VALUE` if you only want to fail back to the first factory when the current connection fails.
549
+
Set `refreshSharedInterval` to only attempt to reconnect with the first factory after that time has expired; setting it to `Long.MAX_VALUE` (default) if you only want to fail back to the first factory when the current connection fails.
551
550
552
551
Set `closeOnRefresh` to close the "old" connection after a refresh actually creates a new connection.
553
552
554
553
IMPORTANT: These properties do not apply if any of the delegate factories is a `CachingClientConnectionFactory` because the connection caching is handled there; in that case the list of connection factories will always be consulted to get a connection.
555
554
555
+
Starting with version 5.3, these default to `Long.MAX_VALUE` and `true` so the factory only attempts to fail back when the current connection fails.
556
+
To revert to the default behavior of previous versions, set them to `0` and `false`.
0 commit comments