Files
rocketmq/proxy
EnableAsync 832562f028 [ISSUE #8920] Refactor SSL context loading process to support multiple protocols dynamic loading (#9483)
* feat(proxy): 添加 gRPC 和 Remoting 服务器的 TLS 证书热更新支持

- 在 GrpcServer 和 RemotingProtocolServer 中添加文件监视服务,用于监控 TLS 证书和密钥的变化
- 实现证书和密钥变更时重新加载 SSL 上下文的逻辑
- 优化 ProxyAndTlsProtocolNegotiator 中的 SSL 上下文加载过程
- 添加日志记录,方便调试和监控 TLS 相关操作

* refactor(proxy): 重构 gRPC 证书监控逻辑并添加单元测试

- 重构 GrpcServer 中的证书监控逻辑,提取到独立的 GrpcCertKeyFileWatchListener 类中
- 优化证书变更处理流程,提高代码可读性和维护性
- 新增 GrpcServerTest 类,为 gRPC服务器和证书监控添加单元测试- 测试覆盖了各种证书变更场景,包括单独变更和组合变更
- 验证了证书变更时 SSLContext 的重新加载和错误处理

Signed-off-by: Async <raisinata@foxmail.com>

* refactor(proxy): 重构 gRPC 证书监控逻辑并添加单元测试

- 重构 GrpcServer 中的证书监控逻辑,提取到独立的 GrpcCertKeyFileWatchListener 类中
- 优化证书变更处理流程,提高代码可读性和维护性
- 新增 GrpcServerTest 类,为 gRPC服务器和证书监控添加单元测试- 测试覆盖了各种证书变更场景,包括单独变更和组合变更
- 验证了证书变更时 SSLContext 的重新加载和错误处理

Signed-off-by: Async <raisinata@foxmail.com>

* fix: code format

Signed-off-by: Async <raisinata@foxmail.com>

* test: add test cases

Signed-off-by: Async <raisinata@foxmail.com>

* fix: code format

Signed-off-by: Async <raisinata@foxmail.com>

* refactor(proxy): 重构 TLS证书更新逻辑

- 移除 FileWatchService,改用 TlsCertificateManager 统一管理 TLS证书
- 实现 TlsContextReloadListener 接口,响应 TLS 证书更新
- 优化 GrpcServer 和 RemotingProtocolServer 中的 TLS 证书更新逻辑
- 新增单元测试验证 TLS 证书更新功能

Signed-off-by: Async <raisinata@foxmail.com>

* test(proxy): 优化 TLS 相关测试用例

- 重构了多个测试类中的重复代码- 提高了测试的可读性和维护性
- 确保在测试中正确关闭资源

Signed-off-by: Async <raisinata@foxmail.com>

* refactor(proxy): 优化代码导入结构

- 移除了不必要的导入项
- 显式导入了所有活动类,提高了代码的可读性和维护性

Signed-off-by: Async <raisinata@foxmail.com>

* update

* fix: no static

Signed-off-by: Async <raisinata@foxmail.com>

* fix: add SingletonHolder for TlsCertificateManager

Signed-off-by: Async <raisinata@foxmail.com>

* refactor

* refactor(proxy): 重构 TLS证书管理

- 将 TlsCertificateManager 实例化移至 ProxyStartup 类
- 更新 GrpcServer 和 RemotingProtocolServer 类以使用 TlsCertificateManager
- 移除冗余的 TLS 证书管理相关测试用例
- 优化 TLS 上下文重载逻辑

Signed-off-by: Async <raisinata@foxmail.com>

* refactor(proxy): 优化日志信息内容

- 将 cert file changed 日志信息改为更通用的 File changed
- 保持代码风格一致性,提高日志的可读性和维护性

Signed-off-by: Async <raisinata@foxmail.com>

* test(proxy): 重构并增强 TlsCertificateManager 测试用例- 重新设计测试用例,使用临时文件模拟证书和密钥
- 增加对 TlsCertificateManager 各种方法的单元测试
- 涉及到的测试场景包括:
  - 构造函数
  - 启动和关闭
  - 注册和注销监听器
  - 文件变更通知(证书、密钥、未知文件等)
  - 多个监听器的情况
  - 监听器抛出异常的情况
  - 增加对内部 CertKeyFileWatchListener 的测试

Signed-off-by: Async <raisinata@foxmail.com>

* refactor

* test(proxy): 优化 TlsCertificateManager 单元测试

-移除了未使用的 import 语句
- 替换了 import static语句,使其更加有序
- 删除了未使用的静态方法断言(verify、times、never)
- 重置了 mock 对象以避免测试之间的干扰

Signed-off-by: Async <raisinata@foxmail.com>

* fix format

Signed-off-by: Async <raisinata@foxmail.com>

* fix format

Signed-off-by: Async <raisinata@foxmail.com>

* fix format

Signed-off-by: Async <raisinata@foxmail.com>

* fix format

Signed-off-by: Async <raisinata@foxmail.com>

* fix format

Signed-off-by: Async <raisinata@foxmail.com>

* fix format

Signed-off-by: Async <raisinata@foxmail.com>

* fix format

Signed-off-by: Async <raisinata@foxmail.com>

* fix format

Signed-off-by: Async <raisinata@foxmail.com>

---------

Signed-off-by: Async <raisinata@foxmail.com>
2025-06-27 09:56:19 +08:00
..
2022-07-13 19:18:03 +08:00

rocketmq-proxy

Introduction

RocketMQ Proxy is a stateless component that makes full use of the newly introduced pop consumption mechanism to achieve stateless consumption behavior. gRPC protocol is supported by Proxy now and all the message types including normal, fifo, transaction and delay are supported via pop consumption mode. Proxy will translate incoming traffic into customized Remoting protocol to access Broker and Namesrv.

Proxy also handles SSL, authorization/authentication and logging/tracing/metrics and is in charge of connection management and traffic governance.

Multi-language support.

gRPC combined with Protocol Buffer makes it easy to implement clients with both java and other programming languages while the server side doesn't need extra work to support different programming languages. See rocketmq-clients for more information.

Multi-protocol support.

With Proxy served as a traffic interface, it's convenient to implement multiple protocols upon proxy. gRPC protocol is implemented first and the customized Remoting protocol will be implemented later. HTTP/1.1 will also be taken into consideration.

Architecture

RocketMQ Proxy has two deployment modes: Cluster mode and Local mode. With both modes, Pop mode is natively supported in Proxy.

Cluster mode

While in Cluster mode, Proxy is an independent cluster that communicates with Broker with remote procedure call. In this scenario, Proxy acts as a stateless computing component while Broker is a stateful component with local storage. This form of deployment introduces the architecture of separation of computing and storage for RocketMQ.

Due to the separation of computing and storage, RocketMQ Proxy can be scaled out indefinitely in Cluster mode to handle traffic peak while Broker can focus on storage engine and high availability.

Local mode

Proxy in Local mode has more similarity with RocketMQ 4.x version, which is easily deployed or upgraded for current RocketMQ users. With Local mode, Proxy deployed with Broker in the same process with inter-process communication so the network overhead is reduced compared to Cluster mode.

Deploy guide

See Proxy Deployment