0

I have made a REST Web Service to send SMSs using a HSDPA USB modem. I am using SMSLib in Java to send SMSs. Every time the web service is invoked, I create the gateway start the service, send message, stop service and remove gateway. This takes about 20 seconds for each message. I found that starting the service takes a lot of time. This is the part of code I use to send SMSs

        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

Is there a way I can start the service once if it is not started and use it to send a message when ever the web service is invoked?

Harlan Gray
  • 341
  • 6
  • 20

1 Answers1

1

Why dont you group the messages and send all in one go?

Service.getInstance().sendMessages(messageList, gateway.getGatewayId()); 
Sheetal Mohan Sharma
  • 2,908
  • 1
  • 23
  • 24