@@ -134,7 +134,8 @@ public class ConnectionFactory implements Cloneable {
134
134
135
135
private boolean automaticRecovery = true ;
136
136
private boolean topologyRecovery = true ;
137
-
137
+ private ExecutorService topologyRecoveryExecutor ;
138
+
138
139
// long is used to make sure the users can use both ints
139
140
// and longs safely. It is unlikely that anybody'd need
140
141
// to use recovery intervals > Integer.MAX_VALUE in practice.
@@ -346,7 +347,7 @@ public void setUri(String uriString)
346
347
setUri (new URI (uriString ));
347
348
}
348
349
349
- private String uriDecode (String s ) {
350
+ private static String uriDecode (String s ) {
350
351
try {
351
352
// URLDecode decodes '+' to a space, as for
352
353
// form encoding. So protect plus signs.
@@ -531,7 +532,6 @@ public void setSocketFactory(SocketFactory factory) {
531
532
*
532
533
* @see #setSocketConfigurator(SocketConfigurator)
533
534
*/
534
- @ SuppressWarnings ("unused" )
535
535
public SocketConfigurator getSocketConfigurator () {
536
536
return socketConf ;
537
537
}
@@ -727,7 +727,6 @@ public void setAutomaticRecoveryEnabled(boolean automaticRecovery) {
727
727
* @return true if topology recovery is enabled, false otherwise
728
728
* @see <a href="http://www.rabbitmq.com/api-guide.html#recovery">Automatic Recovery</a>
729
729
*/
730
- @ SuppressWarnings ("unused" )
731
730
public boolean isTopologyRecoveryEnabled () {
732
731
return topologyRecovery ;
733
732
}
@@ -740,6 +739,27 @@ public boolean isTopologyRecoveryEnabled() {
740
739
public void setTopologyRecoveryEnabled (boolean topologyRecovery ) {
741
740
this .topologyRecovery = topologyRecovery ;
742
741
}
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
+ }
743
763
744
764
public void setMetricsCollector (MetricsCollector metricsCollector ) {
745
765
this .metricsCollector = metricsCollector ;
@@ -1039,6 +1059,7 @@ public ConnectionParams params(ExecutorService consumerWorkServiceExecutor) {
1039
1059
result .setNetworkRecoveryInterval (networkRecoveryInterval );
1040
1060
result .setRecoveryDelayHandler (recoveryDelayHandler );
1041
1061
result .setTopologyRecovery (topologyRecovery );
1062
+ result .setTopologyRecoveryExecutor (topologyRecoveryExecutor );
1042
1063
result .setExceptionHandler (exceptionHandler );
1043
1064
result .setThreadFactory (threadFactory );
1044
1065
result .setHandshakeTimeout (handshakeTimeout );
0 commit comments