Class SmsService

java.lang.Object
org.jivesoftware.util.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
  • Field Details

    • SMPP_CONNECTIONS_MAX_AMOUNT

      public static final SystemProperty<Integer> SMPP_CONNECTIONS_MAX_AMOUNT
      The maximum amount of SMPP connections that the SMS Service will maintain.
    • SMPP_CONNECTIONS_IDLE

      public static final SystemProperty<Duration> SMPP_CONNECTIONS_IDLE
      Time after which idle SMPP connections used by the SMS Service are allowed to be evicted.
    • SMPP_SOURCE_TON

      public static final SystemProperty<org.jsmpp.bean.TypeOfNumber> SMPP_SOURCE_TON
      The type-of-number value for the source of SMS messages.
    • SMPP_SOURCE_NPI

      public static final SystemProperty<org.jsmpp.bean.NumberingPlanIndicator> SMPP_SOURCE_NPI
      The number-plan-indicator value for the source of SMS messages.
    • SMPP_SOURCE_ADDRESS

      public static final SystemProperty<String> SMPP_SOURCE_ADDRESS
      The source address of SMS messages.
    • SMPP_DESTINATION_TON

      public static final SystemProperty<org.jsmpp.bean.TypeOfNumber> SMPP_DESTINATION_TON
      The type-of-number value for the destination of SMS messages.
    • SMPP_DESTINATION_NPI

      public static final SystemProperty<org.jsmpp.bean.NumberingPlanIndicator> SMPP_DESTINATION_NPI
      The number-plan-indicator value for the destination of SMS messages.
    • SMPP_HOST

      public static final SystemProperty<String> SMPP_HOST
      The host name of your SMPP Server or SMSC, i.e. smsc.example.org.
    • SMPP_PORT

      public static final SystemProperty<Integer> SMPP_PORT
      The port on which the SMSC is listening.
    • SMPP_SYSTEMID

      public static final SystemProperty<String> SMPP_SYSTEMID
      The 'user name' to use when connecting to the SMSC.
    • SMPP_PASSWORD

      public static final SystemProperty<String> SMPP_PASSWORD
      The password that authenticates the systemId value when connecting to the SMSC.
    • SMPP_SYSTEMTYPE

      public static final SystemProperty<String> SMPP_SYSTEMTYPE
      An optional system type, which, if defined, will be used when connecting to the SMSC.
    • SMPP_RECEIVE_TON

      public static final SystemProperty<org.jsmpp.bean.TypeOfNumber> SMPP_RECEIVE_TON
      The type-of-number value for 'receiving' SMS messages.
    • SMPP_RECEIVE_NPI

      public static final SystemProperty<org.jsmpp.bean.NumberingPlanIndicator> SMPP_RECEIVE_NPI
      The number-plan-indicator value for 'receiving' SMS messages.
  • Method Details

    • 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 https://www.smssolutions.net/tutorials/smpp/smpperrorcodes/
      Parameters:
      ex - The exception in which to search for a command status.
      Returns:
      a human-readable error message.