Skip to content

Commit c3c4101

Browse files
authored
refactor(proxy): Make TLS certificate watch interval configurable (#9513)
refactor(proxy): Make TLS certificate watch interval configurable
1 parent 7cb1b1e commit c3c4101

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

proxy/src/main/java/org/apache/rocketmq/proxy/config/ProxyConfig.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public class ProxyConfig implements ConfigFile {
8383
private boolean tlsTestModeEnable = true;
8484
private String tlsKeyPath = ConfigurationManager.getProxyHome() + "/conf/tls/rocketmq.key";
8585
private String tlsCertPath = ConfigurationManager.getProxyHome() + "/conf/tls/rocketmq.crt";
86+
private int tlsCertWatchIntervalMs = 60 * 60 * 1000; // 1 hour
8687
/**
8788
* gRPC
8889
*/
@@ -325,6 +326,14 @@ public void parseDelayLevel() {
325326
}
326327
}
327328

329+
public int getTlsCertWatchIntervalMs() {
330+
return tlsCertWatchIntervalMs;
331+
}
332+
333+
public void setTlsCertWatchIntervalMs(int tlsCertWatchIntervalMs) {
334+
this.tlsCertWatchIntervalMs = tlsCertWatchIntervalMs;
335+
}
336+
328337
public String getRocketMQClusterName() {
329338
return rocketMQClusterName;
330339
}

proxy/src/main/java/org/apache/rocketmq/proxy/service/cert/TlsCertificateManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* limitations under the License.
1616
*/
1717
package org.apache.rocketmq.proxy.service.cert;
18+
1819
import org.apache.rocketmq.common.constant.LoggerName;
1920
import org.apache.rocketmq.common.utils.StartAndShutdown;
2021
import org.apache.rocketmq.logging.org.slf4j.Logger;
@@ -39,7 +40,7 @@ public TlsCertificateManager() {
3940
ConfigurationManager.getProxyConfig().getTlsKeyPath()
4041
},
4142
new CertKeyFileWatchListener(),
42-
60 * 60 * 1000 /* 1 hour */
43+
ConfigurationManager.getProxyConfig().getTlsCertWatchIntervalMs()
4344
);
4445
} catch (Exception e) {
4546
log.error("Failed to initialize TLS certificate watch service", e);
@@ -107,7 +108,7 @@ private void notifyContextReload() {
107108
for (TlsContextReloadListener listener : reloadListeners) {
108109
try {
109110
listener.onTlsContextReload();
110-
} catch (Exception e) {
111+
} catch (Throwable e) {
111112
log.error("Failed to notify TLS context reload to listener: " + listener, e);
112113
}
113114
}

0 commit comments

Comments
 (0)