我创建了一个 REST Web 服务来使用 HSDPA USB 调制解调器发送短信。我正在 Java 中使用 SMSLib 发送短信。每次调用 Web 服务时,我都会创建网关,启动服务、发送消息、停止服务并删除网关。每条消息大约需要 20 秒。我发现启动服务需要花费很多时间。 这是我用来发送短信的代码部分
Service.getInstance().addGateway(gateway);
Service.getInstance().startService();
OutboundMessage msg = new OutboundMessage(phoneNumber, message);
if (Service.getInstance().sendMessage(msg)) {
result = "Message sent successfully!!";
} else {
result = "Could not send message.";
}
Service.getInstance().stopService();
Service.getInstance().removeGateway(gateway);//remove the gateway
有没有一种方法可以在服务未启动的情况下启动一次,并在调用 Web 服务时使用它发送消息?
最佳答案
为什么不将消息分组并一次性发送?
Service.getInstance().sendMessages(messageList, gateway.getGatewayId());
关于java - 使用 SMSLib 和 Web 服务发送 SMS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39096574/