SMSGate is a comprehensive SMS gateway framework that provides support for multiple SMS protocols including CMPP (China Mobile), SMPP (Short Message Peer-to-Peer), SGIP (China Unicom), and SMGP (China Telecom). Built on the Netty framework, SMSGate offers asynchronous network communication capabilities with robust session management, message processing, and protocol handling features.
SMSGate 是一个全面的短信网关框架,支持多种短信协议,包括 CMPP(中国移动)、SMPP(短消息对等)、SGIP(中国联通)和 SMGP(中国电信)。基于 Netty 框架构建,SMSGate 提供异步网络通信能力,具有强大的会话管理、消息处理和协议处理功能。
This document provides a technical overview of the SMSGate system architecture, its core components, and the relationships between them. For detailed information on specific components, refer to their respective wiki pages.
本文档提供了 SMSGate 系统架构的技术概述,其核心组件及其之间的关系。有关特定组件的详细信息,请参阅各自的维基页面。
SMSGate serves as a flexible, high-performance SMS gateway that enables:
SMSGate 是一款灵活、高性能的短信网关,它能够实现:
The framework is designed for high throughput (tested at 35K messages/second) while maintaining reliability through message persistence and retry mechanisms.
该框架旨在实现高吞吐量(已测试达到每秒 35K 条消息)的同时,通过消息持久化和重试机制来保证可靠性。
Sources: README.md11-15 README.md245-265 README.md272-273
来源:README.md11-15README.md245-265README.md272-273
The following diagram illustrates the high-level architecture of the SMSGate system:
以下图示展示了 SMSGate 系统的高级架构:
At the core of the system is the EndpointManager
singleton, which manages all endpoints and their lifecycles. Endpoints are represented by EndpointEntity
objects, which can be either clients or servers. Each endpoint has an associated EndpointConnector
that manages connections and sets up the Netty channel pipeline with appropriate handlers for session management, message encoding/decoding, and business logic.
系统的核心是 EndpointManager
单例,它管理所有端点和它们的生命周期。端点由 EndpointEntity
对象表示,可以是客户端或服务器。每个端点都有一个关联的 EndpointConnector
,它管理连接并设置 Netty 通道管道,带有适当的处理程序以进行会话管理、消息编解码和业务逻辑。
Sources: README.md285-317
来源:README.md285-317
The following diagram shows the inheritance structure for the various protocol implementations:
以下图表显示了各种协议实现的继承结构:
Each protocol has both client and server implementations, and server endpoints have child entities for individual connections. The code structure follows a consistent pattern across all supported protocols, making it easier to extend and maintain.
每个协议都有客户端和服务器实现,服务器端点为每个连接有子实体。代码结构在所有支持的协议中遵循一致的模式,使得扩展和维护更加容易。
Sources: README.md288-296
来源:README.md288-296
The following sequence diagram illustrates how messages flow through the SMSGate system:
以下序列图说明了消息如何在 SMSGate 系统中流动:
This diagram shows the complete lifecycle of a message in the system, from connection establishment to message processing to connection termination.
该图展示了系统内消息的完整生命周期,从连接建立到消息处理再到连接终止。
Sources: README.md334-347 README.md143-156
来源:README.md334-347README.md143-156
The EndpointManager
is a singleton that manages all endpoints, handling their lifecycle including creation, opening, closing, and reconnection. It's responsible for adding endpoint entities, opening/closing endpoints, and maintaining the connection check task.
EndpointManager
是一个单例,负责管理所有端点,处理它们的生命周期,包括创建、打开、关闭和重新连接。它负责添加端点实体、打开/关闭端点以及维护连接检查任务。
EndpointManager
├── addEndpointEntity(EndpointEntity)
├── openEndpoint(EndpointEntity)
├── openAll()
├── close()
└── startConnectionCheckTask()
Sources: README.md314-316
来源:README.md314-316
The EndpointEntity
class and its subclasses represent connection endpoints with their configurations. Each endpoint includes information such as host, port, credentials, and protocol-specific settings.
EndpointEntity
类及其子类代表具有配置的连接端点。每个端点都包含诸如主机、端口、凭据和协议特定设置等信息。
Entity Type 实体类型 | Description 描述 | Main Properties 主要属性 |
---|---|---|
ClientEndpointEntity 客户端端点实体 | Initiates connections to servers 初始化与服务器建立连接 | host, port, credentials, maxChannels 主机、端口、凭证、最大通道数 |
ServerEndpointEntity 服务器端点实体 | Listens for incoming connections 监听传入的连接 | host, port, children 主机,端口,子节点 |
ServerChildEndpointEntity 服务器子端点实体 | Represents individual server connections 表示单个服务器连接 | credentials, businessHandlers 凭证, 业务处理器 |
Client entities use their configured connection information to establish connections to servers, while server entities listen on specified ports and create child entities for each incoming connection.
客户端实体使用其配置的连接信息与服务器建立连接,而服务器实体监听指定的端口并为每个传入连接创建子实体。
Sources: README.md288-298
来源: README.md288-298
The EndpointConnector
interface and its implementations are responsible for managing connections and setting up Netty channel pipelines:
EndpointConnector
接口及其实现负责管理连接和设置 Netty 通道管道:
The connectors manage the lifecycle of connections, adding appropriate handlers to the Netty pipeline, and maintaining lists of active channels.
连接器管理连接的生命周期,向 Netty 管道添加适当的处理程序,并维护活动通道的列表。
Sources: README.md300-312
来源:README.md300-312
The session management components handle connection authentication, message tracking, and retransmission:
会话管理组件处理连接认证、消息跟踪和重传:
Each protocol has its own implementation of these managers to handle protocol-specific details.
每个协议都有自己的管理器实现,以处理特定于协议的细节。
Sources: README.md318-321 README.md322-324
来源:README.md 第 318-321 行 README.md 第 322-324 行
The framework automatically handles long SMS messages (exceeding standard SMS length) by splitting them into fragments and reassembling them:
框架自动处理超出标准短信长度的长短信消息,通过将其分割成片段并重新组装:
The system can be configured to use Redis for distributed long message caching in cluster environments.
系统可以配置为在集群环境中使用 Redis 进行分布式长消息缓存。
Sources: README.md143-156 README.md157-162
源文件: README.md143-156README.md157-162
To use SMSGate, you need to:
要使用 SMSGate,您需要:
<dependency> <groupId>com.chinamobile.cmos</groupId> <artifactId>sms-core</artifactId> <version>2.1.13.6</version> </dependency>
For more detailed information on configuration and usage, see the Core Architecture and Protocol Support pages.
关于配置和使用的详细信息,请参阅核心架构和协议支持页面。
Sources: README.md9-15 README.md396-482
来源:README.md9-15README.md396-482
To send SMS messages, you need to:
发送短信消息,您需要:
The framework handles message encoding, splitting long messages, and tracking delivery status.
框架处理消息编码、分割长消息和跟踪投递状态。
Sources: README.md31-36 来源:README.md31-36
To receive SMS messages, you need to:
接收短信消息,您需要:
Business handlers can process various message types including delivery reports, incoming messages, and other protocol-specific messages.
业务处理器可以处理各种消息类型,包括投递报告、入站消息和其他协议特定消息。
Sources: README.md58-68 来源:README.md58-68
SMSGate includes several advanced features:
SMSGate 包含多个高级功能:
For more information on these features, see the Advanced Features section.
关于这些功能的更多信息,请参阅高级功能部分。
Sources: README.md82-93 README.md157-162 README.md170-176
来源:README.md82-93README.md157-162README.md170-176
Try DeepWiki on your private codebase with Devin
在您的私有代码库中尝试 DeepWiki,与 Devin 一起