@@ -129,7 +129,8 @@ public class ConnectionFactory implements Cloneable {
129
129
130
130
private boolean automaticRecovery = true ;
131
131
private boolean topologyRecovery = true ;
132
-
132
+ private ExecutorService topologyRecoveryExecutor ;
133
+
133
134
// long is used to make sure the users can use both ints
134
135
// and longs safely. It is unlikely that anybody'd need
135
136
// to use recovery intervals > Integer.MAX_VALUE in practice.
@@ -341,7 +342,7 @@ public void setUri(String uriString)
341
342
setUri (new URI (uriString ));
342
343
}
343
344
344
- private String uriDecode (String s ) {
345
+ private static String uriDecode (String s ) {
345
346
try {
346
347
// URLDecode decodes '+' to a space, as for
347
348
// form encoding. So protect plus signs.
@@ -525,7 +526,6 @@ public void setSocketFactory(SocketFactory factory) {
525
526
*
526
527
* @see #setSocketConfigurator(SocketConfigurator)
527
528
*/
528
- @ SuppressWarnings ("unused" )
529
529
public SocketConfigurator getSocketConfigurator () {
530
530
return socketConf ;
531
531
}
@@ -703,7 +703,6 @@ public void setAutomaticRecoveryEnabled(boolean automaticRecovery) {
703
703
* @return true if topology recovery is enabled, false otherwise
704
704
* @see <a href="http://www.rabbitmq.com/api-guide.html#recovery">Automatic Recovery</a>
705
705
*/
706
- @ SuppressWarnings ("unused" )
707
706
public boolean isTopologyRecoveryEnabled () {
708
707
return topologyRecovery ;
709
708
}
@@ -716,6 +715,24 @@ public boolean isTopologyRecoveryEnabled() {
716
715
public void setTopologyRecoveryEnabled (boolean topologyRecovery ) {
717
716
this .topologyRecovery = topologyRecovery ;
718
717
}
718
+
719
+ /**
720
+ * Get the executor to use for parallel topology recovery. If null (the default), recovery is done single threaded on the main connection thread.
721
+ * @return thread pool executor
722
+ */
723
+ public ExecutorService getTopologyRecoveryExecutor () {
724
+ return topologyRecoveryExecutor ;
725
+ }
726
+
727
+ /**
728
+ * Set the executor to use for parallel topology recovery. If null (the default), recovery is done single threaded on the main connection thread.
729
+ * It is recommended to pass a ThreadPoolExecutor that will allow its core threads to timeout so these threads can die when recovery is complete.
730
+ * Note: your {@link ExceptionHandler#handleTopologyRecoveryException(Connection, Channel, TopologyRecoveryException)} method should be thread-safe.
731
+ * @param topologyRecoveryExecutor thread pool executor
732
+ */
733
+ public void setTopologyRecoveryExecutor (final ExecutorService topologyRecoveryExecutor ) {
734
+ this .topologyRecoveryExecutor = topologyRecoveryExecutor ;
735
+ }
719
736
720
737
public void setMetricsCollector (MetricsCollector metricsCollector ) {
721
738
this .metricsCollector = metricsCollector ;
@@ -1015,6 +1032,7 @@ public ConnectionParams params(ExecutorService consumerWorkServiceExecutor) {
1015
1032
result .setNetworkRecoveryInterval (networkRecoveryInterval );
1016
1033
result .setRecoveryDelayHandler (recoveryDelayHandler );
1017
1034
result .setTopologyRecovery (topologyRecovery );
1035
+ result .setTopologyRecoveryExecutor (topologyRecoveryExecutor );
1018
1036
result .setExceptionHandler (exceptionHandler );
1019
1037
result .setThreadFactory (threadFactory );
1020
1038
result .setHandshakeTimeout (handshakeTimeout );
0 commit comments