Package org.jivesoftware.util
Class SmsService
java.lang.Object
org.jivesoftware.util.SmsService
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final SystemProperty<Duration>Time after which idle SMPP connections used by the SMS Service are allowed to be evicted.static final SystemProperty<Integer>The maximum amount of SMPP connections that the SMS Service will maintain.static final SystemProperty<org.jsmpp.bean.NumberingPlanIndicator>The number-plan-indicator value for the destination of SMS messages.static final SystemProperty<org.jsmpp.bean.TypeOfNumber>The type-of-number value for the destination of SMS messages.static final SystemProperty<String>The host name of your SMPP Server or SMSC, i.e. smsc.example.org.static final SystemProperty<String>The password that authenticates the systemId value when connecting to the SMSC.static final SystemProperty<Integer>The port on which the SMSC is listening.static final SystemProperty<org.jsmpp.bean.NumberingPlanIndicator>The number-plan-indicator value for 'receiving' SMS messages.static final SystemProperty<org.jsmpp.bean.TypeOfNumber>The type-of-number value for 'receiving' SMS messages.static final SystemProperty<String>The source address of SMS messages.static final SystemProperty<org.jsmpp.bean.NumberingPlanIndicator>The number-plan-indicator value for the source of SMS messages.static final SystemProperty<org.jsmpp.bean.TypeOfNumber>The type-of-number value for the source of SMS messages.static final SystemProperty<String>The 'user name' to use when connecting to the SMSC.static final SystemProperty<String>An optional system type, which, if defined, will be used when connecting to the SMSC. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringChecks 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.static SmsServicevoidCauses a new SMS message to be sent.voidsendImmediately(String message, String recipient) Causes a new SMS message to be sent.
-
Field Details
-
SMPP_CONNECTIONS_MAX_AMOUNT
The maximum amount of SMPP connections that the SMS Service will maintain. -
SMPP_CONNECTIONS_IDLE
Time after which idle SMPP connections used by the SMS Service are allowed to be evicted. -
SMPP_SOURCE_TON
The type-of-number value for the source of SMS messages. -
SMPP_SOURCE_NPI
The number-plan-indicator value for the source of SMS messages. -
SMPP_SOURCE_ADDRESS
The source address of SMS messages. -
SMPP_DESTINATION_TON
The type-of-number value for the destination of SMS messages. -
SMPP_DESTINATION_NPI
The number-plan-indicator value for the destination of SMS messages. -
SMPP_HOST
The host name of your SMPP Server or SMSC, i.e. smsc.example.org. -
SMPP_PORT
The port on which the SMSC is listening. -
SMPP_SYSTEMID
The 'user name' to use when connecting to the SMSC. -
SMPP_PASSWORD
The password that authenticates the systemId value when connecting to the SMSC. -
SMPP_SYSTEMTYPE
An optional system type, which, if defined, will be used when connecting to the SMSC. -
SMPP_RECEIVE_TON
The type-of-number value for 'receiving' SMS messages. -
SMPP_RECEIVE_NPI
The number-plan-indicator value for 'receiving' SMS messages.
-
-
Method Details
-
getInstance
-
send
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
Causes a new SMS message to be sent. This method differs fromsend(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
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.
-