Class SmsService


  • public class SmsService
    extends Object
    A service to send SMS messages.

    This class is configured with a set of Jive properties. Note that each service provider can require a different set of properties to be set.

    • sms.smpp.connections.maxAmount -- the maximum amount of connections. The default value is one.
    • sms.smpp.connections.idleMillis -- time (in ms) after which idle connections are allowed to be evicted. Defaults to two minutes.
    • sms.smpp.host -- the host name of your SMPP Server or SMSC, i.e. smsc.example.org. The default value is "localhost".
    • sms.smpp.port -- the port on which the SMSC is listening. Defaults to 2775.
    • sms.smpp.systemId -- the 'user name' to use when connecting to the SMSC.
    • sms.smpp.password -- the password that authenticates the systemId value when connecting to the SMSC.
    • sms.smpp.systemType -- an optional system type, which, if defined, will be used when connecting to the SMSC.
    • sms.smpp.receive.ton -- The type-of-number value for 'receiving' SMS messages. Defaults to 'UNKNOWN'.
    • sms.smpp.receive.npi -- The number-plan-indicator value for 'receiving' SMS messages. Defaults to 'UNKNOWN'.
    • sms.smpp.source.ton -- The type-of-number value for the source of SMS messages. Defaults to 'UNKNOWN'.
    • sms.smpp.source.npi -- The number-plan-indicator value for the source of SMS messages. Defaults to 'UNKNOWN'.
    • sms.smpp.source.address -- The source address of SMS messages.
    • sms.smpp.destination.ton -- The type-of-number value for the destination of SMS messages. Defaults to 'UNKNOWN'.
    • sms.smpp.destination.npi -- The number-plan-indicator value for the destination of SMS messages. Defaults to 'UNKNOWN'.
    Author:
    Guus der Kinderen, guus@goodbytes.nl
    • Method Detail

      • getInstance

        public static SmsService getInstance()
      • send

        public void send​(String message,
                         String recipient)
        Causes a new SMS message to be sent. Note that the message is sent asynchronously. This method does not block. A successful invocation does not guarantee successful delivery
        Parameters:
        message - The body of the message (cannot be null or empty).
        recipient - The address / phone number to which the message is to be send (cannot be null or empty).
      • sendImmediately

        public void sendImmediately​(String message,
                                    String recipient)
                             throws Exception
        Causes a new SMS message to be sent. This method differs from send(String, String) in that the message is sent before this method returns, rather than queueing the messages to be sent later (in an async fashion). As a result, any exceptions that occur while sending the message are thrown by this method (which can be useful to test the configuration of this service).
        Parameters:
        message - The body of the message (cannot be null or empty).
        recipient - The address / phone number to which the message is to be send (cannot be null or empty).
        Throws:
        Exception - On any problem.
      • getDescriptiveMessage

        public static String getDescriptiveMessage​(Throwable ex)
        Checks if an exception in the chain of the provided throwable contains a 'command status' that can be translated in a somewhat more helpful error message. The list of error messages was taken from http://www.smssolutions.net/tutorials/smpp/smpperrorcodes/
        Parameters:
        ex - The exception in which to search for a command status.
        Returns:
        a human readable error message.