SMSLIB在多个电话号码上发送批量消息?

时间:2018-09-25 11:45:23

标签: java smslib

问题: 通过在客户列表中的每个客户中发送多条消息,我的项目如何花更少的时间?

这是我的短信课程:

  public void sendSMS(String port, String phoneNumber, String message) throws Exception {

                try {
        OutboundNotification outboundNotification = new OutboundNotification();
        SerialModemGateway gateway = new SerialModemGateway("", port, 9600, "", "");
        gateway.setInbound(true);
        gateway.setOutbound(true);
        //gateway.setSimPin("0000");
        Service.getInstance().setOutboundMessageNotification(outboundNotification);
        Service.getInstance().addGateway(gateway);
         Service.getInstance().startService();
        OutboundMessage msg = new OutboundMessage(phoneNumber, message);
        Service.getInstance().sendMessage(msg);
        Service.getInstance().stopService();
        Service.getInstance().removeGateway(gateway);
        } catch (Exception ex) {
                    System.err.println("test");    
                    Logger.getLogger(SMS.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

这是我运行时代码的流向,我在另一个类中调用sendsms.class

for (Client client1 : client) {
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    String num = "";
                    num = client1.getPhonenumber().trim(); 
                    new SMS().sendSMS("COM7",num, taMessageFilter.getText());
                } catch (Exception ex) {
                    new PopupError().text(ex.getMessage());
                }
            }
        });
        t.start();
        try {
            Thread.sleep(20000);
        } catch (InterruptedException ex) {
            Logger.getLogger(Dsms.class.getName()).log(Level.SEVERE, null, ex);
        }

}

0 个答案:

没有答案