Class BatchSender

java.lang.Object
cloud.opencode.base.sms.batch.BatchSender

public final class BatchSender extends Object
Batch Sender 批量发送器

Advanced batch SMS sender with parallelism and progress tracking.

支持并行和进度跟踪的高级批量短信发送器。

Features | 主要功能:

  • Configurable concurrency and batch size - 可配置并发数和批量大小
  • Progress callback support - 进度回调支持
  • Phone number validation before send - 发送前手机号验证
  • Timeout control - 超时控制

Usage Examples | 使用示例:

BatchSender sender = BatchSender.builder(provider)
    .batchSize(50)
    .concurrency(5)
    .validatePhones(true)
    .build();
BatchResult result = sender.send(messages);

Security | 安全性:

  • Thread-safe: Yes (immutable configuration, thread-safe execution) - 线程安全: 是(不可变配置,线程安全执行)
  • Null-safe: Yes (empty result for null/empty input) - 空值安全: 是(空输入返回空结果)
Since:
JDK 25, opencode-base-sms V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • builder

      public static BatchSender.Builder builder(SmsProvider provider)
      Create builder 创建构建器
      Parameters:
      provider - the SMS provider | 短信提供商
      Returns:
      the builder | 构建器
    • send

      public BatchResult send(List<SmsMessage> messages)
      Send batch messages 批量发送消息
      Parameters:
      messages - the messages | 消息列表
      Returns:
      the batch result | 批量结果
    • sendAsync

      public CompletableFuture<BatchResult> sendAsync(List<SmsMessage> messages)
      Send batch messages asynchronously 异步批量发送消息
      Parameters:
      messages - the messages | 消息列表
      Returns:
      the future result | 异步结果
    • sendToPhones

      public BatchResult sendToPhones(List<String> phones, SmsMessage templateMessage)
      Send to multiple phones with same template 使用相同模板发送给多个手机号
      Parameters:
      phones - the phone numbers | 手机号列表
      templateMessage - the template message | 模板消息
      Returns:
      the batch result | 批量结果