@@ -69,6 +69,7 @@ public class MerchantConfig {
6969 private int socketTimeoutMs ;
7070 private int evictThreadSleepTimeMs ;
7171 private int maxKeepAliveTimeMs ;
72+ private int validateAfterInactivityMs ;
7273 private int timeout ;
7374 private String proxyHost ;
7475 private int proxyPort ;
@@ -324,6 +325,16 @@ public int getMaxKeepAliveTimeMs() {
324325 return maxKeepAliveTimeMs ;
325326 }
326327
328+ /**
329+ * Defines period of inactivity in milliseconds after which persistent connections must be re-validated prior to being
330+ * leased to the consumer. Non-positive value passed to this method disables connection validation.
331+ * This check helps detect connections that have become stale (half-closed) while kept inactive in the pool.
332+ * @return int
333+ */
334+ public int getValidateAfterInactivityMs () {
335+ return validateAfterInactivityMs ;
336+ }
337+
327338 /**
328339 * Getter method for proxyHost
329340 * @return String
@@ -569,6 +580,7 @@ public MerchantConfig(Properties _props, String _merchantID)
569580 maxKeepAliveTimeMs = getIntegerProperty (merchantID , "maxKeepAliveTimeMs" );
570581 }
571582
583+ validateAfterInactivityMs = getIntegerProperty (merchantID , "validateAfterInactivityMs" , 2000 );
572584 shutdownHookEnabled =getBooleanProperty (merchantID , "enabledShutdownHook" , true );
573585 }
574586
@@ -761,6 +773,7 @@ public String getLogString() {
761773 appendPair (sb , "socketTimeoutMs" , socketTimeoutMs );
762774 appendPair (sb , "evictThreadSleepTimeMs" , evictThreadSleepTimeMs );
763775 appendPair (sb , "maxKeepAliveTimeMs" , maxKeepAliveTimeMs );
776+ appendPair (sb , "validateAfterInactivityMs" , validateAfterInactivityMs );
764777 appendPair (sb , "enabledShutdownHook" , shutdownHookEnabled );
765778 }
766779 appendPair (sb , "timeout" , timeout );
0 commit comments