@@ -141,6 +141,14 @@ public class ConnectionFactory implements Cloneable {
141141 */
142142 private boolean channelShouldCheckRpcResponseType = false ;
143143
144+ /**
145+ * Listener called when a connection gets an IO error trying to write on the socket.
146+ * Default listener triggers connection recovery asynchronously and propagates
147+ * the exception.
148+ * @since 4.5.0
149+ */
150+ private ErrorOnWriteListener errorOnWriteListener ;
151+
144152 /**
145153 * Timeout in ms for work pool enqueuing.
146154 * @since 4.5.0
@@ -984,6 +992,7 @@ public ConnectionParams params(ExecutorService consumerWorkServiceExecutor) {
984992 result .setChannelRpcTimeout (channelRpcTimeout );
985993 result .setChannelShouldCheckRpcResponseType (channelShouldCheckRpcResponseType );
986994 result .setWorkPoolTimeout (workPoolTimeout );
995+ result .setErrorOnWriteListener (errorOnWriteListener );
987996 return result ;
988997 }
989998
@@ -1292,7 +1301,9 @@ public boolean isChannelShouldCheckRpcResponseType() {
12921301 * TCP connection failure. Note this shouldn't happen
12931302 * with clients that set appropriate QoS values.
12941303 * Default is no timeout.
1304+ *
12951305 * @param workPoolTimeout timeout in ms
1306+ * @since 4.5.0
12961307 */
12971308 public void setWorkPoolTimeout (int workPoolTimeout ) {
12981309 this .workPoolTimeout = workPoolTimeout ;
@@ -1301,4 +1312,17 @@ public void setWorkPoolTimeout(int workPoolTimeout) {
13011312 public int getWorkPoolTimeout () {
13021313 return workPoolTimeout ;
13031314 }
1315+
1316+ /**
1317+ * Set a listener to be called when connection gets an IO error trying to write on the socket.
1318+ * Default listener triggers connection recovery asynchronously and propagates
1319+ * the exception. Override the default listener to disable or
1320+ * customise automatic connection triggering on write operations.
1321+ *
1322+ * @param errorOnWriteListener the listener
1323+ * @since 4.5.0
1324+ */
1325+ public void setErrorOnWriteListener (ErrorOnWriteListener errorOnWriteListener ) {
1326+ this .errorOnWriteListener = errorOnWriteListener ;
1327+ }
13041328}
0 commit comments