@@ -134,7 +134,8 @@ public class ConnectionFactory implements Cloneable {
134134
135135 private boolean automaticRecovery = true ;
136136 private boolean topologyRecovery = true ;
137-
137+ private ExecutorService topologyRecoveryExecutor ;
138+
138139 // long is used to make sure the users can use both ints
139140 // and longs safely. It is unlikely that anybody'd need
140141 // to use recovery intervals > Integer.MAX_VALUE in practice.
@@ -346,7 +347,7 @@ public void setUri(String uriString)
346347 setUri (new URI (uriString ));
347348 }
348349
349- private String uriDecode (String s ) {
350+ private static String uriDecode (String s ) {
350351 try {
351352 // URLDecode decodes '+' to a space, as for
352353 // form encoding. So protect plus signs.
@@ -531,7 +532,6 @@ public void setSocketFactory(SocketFactory factory) {
531532 *
532533 * @see #setSocketConfigurator(SocketConfigurator)
533534 */
534- @ SuppressWarnings ("unused" )
535535 public SocketConfigurator getSocketConfigurator () {
536536 return socketConf ;
537537 }
@@ -727,7 +727,6 @@ public void setAutomaticRecoveryEnabled(boolean automaticRecovery) {
727727 * @return true if topology recovery is enabled, false otherwise
728728 * @see <a href="http://www.rabbitmq.com/api-guide.html#recovery">Automatic Recovery</a>
729729 */
730- @ SuppressWarnings ("unused" )
731730 public boolean isTopologyRecoveryEnabled () {
732731 return topologyRecovery ;
733732 }
@@ -740,6 +739,27 @@ public boolean isTopologyRecoveryEnabled() {
740739 public void setTopologyRecoveryEnabled (boolean topologyRecovery ) {
741740 this .topologyRecovery = topologyRecovery ;
742741 }
742+
743+ /**
744+ * Get the executor to use for parallel topology recovery. If null (the default), recovery is done single threaded on the main connection thread.
745+ * @return thread pool executor
746+ * @since 4.7.0
747+ */
748+ public ExecutorService getTopologyRecoveryExecutor () {
749+ return topologyRecoveryExecutor ;
750+ }
751+
752+ /**
753+ * Set the executor to use for parallel topology recovery. If null (the default), recovery is done single threaded on the main connection thread.
754+ * It is recommended to pass a ThreadPoolExecutor that will allow its core threads to timeout so these threads can die when recovery is complete.
755+ * It's developer's responsibility to shut down the executor when it is no longer needed.
756+ * Note: your {@link ExceptionHandler#handleTopologyRecoveryException(Connection, Channel, TopologyRecoveryException)} method should be thread-safe.
757+ * @param topologyRecoveryExecutor thread pool executor
758+ * @since 4.7.0
759+ */
760+ public void setTopologyRecoveryExecutor (final ExecutorService topologyRecoveryExecutor ) {
761+ this .topologyRecoveryExecutor = topologyRecoveryExecutor ;
762+ }
743763
744764 public void setMetricsCollector (MetricsCollector metricsCollector ) {
745765 this .metricsCollector = metricsCollector ;
@@ -1039,6 +1059,7 @@ public ConnectionParams params(ExecutorService consumerWorkServiceExecutor) {
10391059 result .setNetworkRecoveryInterval (networkRecoveryInterval );
10401060 result .setRecoveryDelayHandler (recoveryDelayHandler );
10411061 result .setTopologyRecovery (topologyRecovery );
1062+ result .setTopologyRecoveryExecutor (topologyRecoveryExecutor );
10421063 result .setExceptionHandler (exceptionHandler );
10431064 result .setThreadFactory (threadFactory );
10441065 result .setHandshakeTimeout (handshakeTimeout );
0 commit comments