SMPP
Since Camel 2.2
Both producer and consumer are supported
This component provides access to an SMSC (Short Message Service Center) over the SMPP protocol to send and receive SMS. The JSMPP library is used for the protocol implementation.
The version of the SMPP protocol specification is 3.4 by default and can be set using the component configuration options (field "interfaceVersion").
The Camel component currently operates as an ESME (External Short Messaging Entity) and not as an SMSC itself.
You are also able to execute ReplaceSm, QuerySm, SubmitMulti, CancelSm, and DataSm.
Maven users will need to add the following dependency to their pom.xml for this component:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-smpp</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency> | JSMPP library See the documentation of the JSMPP Library for more details about the underlying library. |
SMS limitations
SMS is neither reliable nor secure. Users who require reliable and secure delivery may want to consider using the XMPP or SIP components instead, combined with a smartphone app supporting the chosen protocol.
-
Reliability: although the SMPP standard offers a range of feedback mechanisms to indicate errors, non-delivery and confirmation of delivery, it is not uncommon for mobile networks to hide or simulate these responses. For example, some networks automatically send a delivery confirmation for every message even if the destination number is invalid or not switched on. Some networks silently drop messages if they think they are spam. Spam detection rules in the network may be very crude, sometimes more than 100 messages per day from a single sender may be considered spam.
-
Security: there is basic encryption for the last hop from the radio tower down to the recipient handset. SMS messages are not encrypted or authenticated in any other part of the network. Some operators allow staff in retail outlets or call centres to browse through the SMS message histories of their customers. Message sender identity can be easily forged. Regulators and even the mobile telephone industry itself have cautioned against the use of SMS in two-factor authentication schemes and other purposes where security is important.
While the Camel component makes it as easy as possible to send messages to the SMS network, it cannot offer an easy solution to these problems.
Commands
The CamelSmppCommand header selects the command the producer sends: SubmitSm (used when the header is missing), ReplaceSm, QuerySm, SubmitMulti, CancelSm or DataSm. The names are case-sensitive. Any other value fails the exchange with an IllegalArgumentException that lists the commands, so a misspelled command such as querySm is not sent as an SMS.
SubmitSm, SubmitMulti and ReplaceSm send the message body as the short message, so they need a body: a message without one fails with an SmppException caused by an InvalidPayloadException. A body that can be read only once, such as a stream, is read once and replaced by its content (a String, or a byte array for an 8-bit message).
The producer sets its result headers, such as CamelSmppId and CamelSmppSentMessageCount, on the message of the exchange. The body and the headers that were set before the send stay, also when the exchange pattern is InOut.
Data coding, alphabet and international character sets
Data coding and alphabet can be specified on a per-message basis. Default values can be specified for the endpoint. It is important to understand the relationship between these options and the way the component acts when more than one value is set.
Data coding is an 8 bit field in the SMPP wire format.
The alphabet corresponds to bits 0–3 of the data coding field. For some types of message, where a message class is used (by setting bit 5 of the data coding field), the lower two bits of the data coding field are not interpreted as alphabet. Only bits 2 and 3 impact the alphabet.
Furthermore, the current version of the JSMPP library only seems to support bits 2 and 3, assuming that bits 0 and 1 are used for message class. This is why the Alphabet class in JSMPP doesn’t support the value 3 (binary 0011) which indicates ISO-8859-1.
Although JSMPP provides a representation of the message class parameter, the Camel component doesn’t currently provide a way to set it other than manually setting the corresponding bits in the data coding field.
When setting the data coding field in the outgoing message, the Camel component considers the following values and uses the first one it can find:
-
the data coding specified in a header
-
the alphabet specified in a header
-
the data coding specified in the endpoint configuration (URI parameter)
In addition to trying to send the data coding value to the SMSC, the Camel component also tries to analyze the message body, converts it to a Java String (Unicode) and converts that to a byte array in the corresponding alphabet. When deciding which alphabet to use in the byte array, the Camel SMPP component does not consider the data coding value (header or configuration), it only considers the specified alphabet (from either the header or endpoint parameter). The exception is an 8-bit message, as described below: its body is sent as bytes, as they are.
A body that is a byte array is sent as it is, without this conversion, when the message is 8-bit: the component looks at the data coding header, then the alphabet header, and, when neither header is set, at the dataCoding and alphabet endpoint options. The message is 8-bit when the value found is 8-bit (data coding 4, or an 8-bit GSM message class such as 0xF7; alphabet 4), or, for the endpoint options, when either option is 8-bit. With an 8-bit header, a body of another type is converted to a byte array in the charset of the exchange. With the endpoint options, only a byte array is sent as it is: text is still encoded with the encoding option. An 8-bit message is split by its length in bytes.
If some characters in the String cannot be represented in the chosen alphabet, they may be replaced by the question mark (?) symbol. Users of the API may want to consider checking if their message body can be converted to ISO-8859-1 before passing it to the component and if not, setting the alphabet header to request UCS-2 encoding. If the alphabet and data coding options are not specified at all, the component does not detect the required encoding or set the data coding for you: the text is encoded for the SMSC default alphabet (0), in the encoding of the endpoint, ISO-8859-1 by default.
The list of alphabet codes is specified in the SMPP specification v3.4, section 5.2.19. One notable limitation of the SMPP specification is that there is no alphabet code for explicitly requesting use of the GSM 3.38 (7-bit) character set. Choosing 0 for the alphabet selects the SMSC default alphabet, this usually means GSM 3.38, but it is not guaranteed. The SMPP gateway Nexmo actually allows the default to be mapped to any other character set with a control panel option. It is suggested that users check with their SMSC operator to confirm exactly which character set is being used as the default.
Message splitting and throttling
After transforming a message body from a String to a byte array, the Camel component is also responsible for splitting the message into parts (within the 140 byte SMS size limit) before passing it to JSMPP. This is completed automatically.
If the GSM 3.38 alphabet is used, the component will pack up to 160 characters into the 140-byte message body. If the 8-bit alphabet (4) is used, then 140 bytes will be allowed within the 140-byte message body. Text in an 8-bit character set (e.g., ISO-8859-1 for Western Europe) is split by 140 bytes only in an 8-bit message (the 8-bit alphabet, or an 8-bit data coding as described above); with the default alphabet, it is split by 160 characters. If 16 bit UCS-2 encoding is used, then just 70 characters fit into each 140-byte message.
Some SMSC providers implement throttling rules. Each part of a message that has been split may be counted separately by the provider’s throttling mechanism. The Camel Throttler component can be useful for throttling messages in the SMPP route before handing them to the SMSC.
URI format
smpp://[username@]hostname[:port][?options] smpps://[username@]hostname[:port][?options]
If no username is provided, then Camel will provide the default value smppclient.
If no port number is provided, then Camel will provide the default value 2775.
If the protocol name is "smpps", camel-smpp will try to use SSLSocket to init a connection to the server. The certificate of the server must be trusted by the JVM, and it must match the host Camel connects to, with the same rules as an HTTPS client: a connection to an IP address needs a certificate that lists that address as a subject alternative name. Set hostnameVerification=false to turn the host check off.
The handshake runs while the connection is being created, so a certificate that does not match makes the producer or consumer fail to start with an IOException caused by an SSLHandshakeException: No subject alternative names matching IP address … found (or No subject alternative DNS name matching … found for a host name). An IP address has to be listed as a subject alternative name of the certificate; a certificate issued for the host name alone does not match a connection made to its address.
Configuring Options
Camel components are configured on two separate levels:
-
component level
-
endpoint level
Configuring Component Options
At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.
For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.
Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.
You can configure components using:
-
the Component DSL.
-
in a configuration file (
application.properties,*.yamlfiles, etc). -
directly in the Java code.
Configuring Endpoint Options
You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.
Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.
A good practice when configuring options is to use Property Placeholders.
Property placeholders provide a few benefits:
-
They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.
-
They allow externalizing the configuration from the code.
-
They help the code to become more flexible and reusable.
The following two sections list all the options, firstly for the component followed by the endpoint.
Component Options
The SMPP component supports the following options which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
The delay in milliseconds before the first attempt to reconnect, after the consumer or producer lost its session to the SMSC (the connection was closed, or the SMSC unbound). A failed connect when the consumer or producer starts is not retried. | 5000 | long | |
The maximum number of attempts to reconnect after the session to the SMSC was lost. When the last attempt fails, a consumer stays disconnected until it is restarted, and a producer fails its exchanges, unless lazySessionCreation is enabled, which connects again for the next exchange. | 2147483647 | int | |
The delay in milliseconds between two attempts to reconnect to the SMSC, after the first attempt failed. | 5000 | long | |
What the producer does with a SubmitSm or SubmitMulti whose body does not fit in one short message: ALLOW sends it in several segments, TRUNCATE sends only its first part, and REJECT fails the exchange with an SmppException caused by a NegativeResponseException with status 1. Some carriers drop the segments after the first, which TRUNCATE does not send. The CamelSmppSplittingPolicy header replaces it. Enum values:
| ALLOW | SmppSplittingPolicy | |
The system_type of the bind request, which tells the SMSC the type of ESME (External Short Message Entity) that binds. SMPP 3.4 allows at most 13 octets, the NULL terminator included. Empty by default. | String | ||
The address_range of the bind request of the consumer: the SME addresses that this ESME serves, as defined in section 5.2.7 of the SMPP 3.4 specification. The SMSC uses it to select the messages that it delivers to the consumer. Empty by default. | String | ||
Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean | |
The destination address that the producer sends with SubmitSm, SubmitMulti, CancelSm and DataSm, for example the phone number of the recipient of a mobile terminated message. The CamelSmppDestAddr header replaces it, with a list of addresses for SubmitMulti. | 1717 | String | |
The numbering plan indicator (NPI) of the destination address that the producer sends with SubmitSm, SubmitMulti, CancelSm and DataSm, with the values of the sourceAddrNpi option. The CamelSmppDestAddrNpi header replaces it; the default is 0. Enum values:
| byte | ||
The type of number (TON) of the destination address that the producer sends with SubmitSm, SubmitMulti, CancelSm and DataSm, with the values of the sourceAddrTon option. The CamelSmppDestAddrTon header replaces it; the default is 0. Enum values:
| byte | ||
Whether the producer connects to the SMSC when it sends its first exchange instead of when it starts, so that the route can start while the SMSC is not available. The producer binds with the systemId and password options, or with headers when allowSystemIdAndPasswordFromHeaders is enabled. | false | boolean | |
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
The id of a route whose consumer receives the messages that the SMSC sends to this producer. The producer then binds as a transceiver (bind_transceiver) instead of a transmitter, and hands each received deliver_sm, data_sm and alert_notification to that route, so that no SMPP consumer is needed. Only tested with a route that starts from a direct endpoint; the route must exist when Camel starts. | String | ||
The numbering plan indicator (NPI) that the producer sends in the addr_npi field of its bind request, with the values of the sourceAddrNpi option. The consumer binds with 0 (unknown). The default is 0. Enum values:
| byte | ||
The priority_flag that the producer sends with SubmitSm and SubmitMulti, from 0 (lowest) to 3 (highest). The CamelSmppPriorityFlag header replaces it; the default is 1. Enum values:
| byte | ||
The protocol_id that the producer sends with SubmitSm and SubmitMulti, which for GSM is set as defined in GSM 03.40. The CamelSmppProtocolId header replaces it; the default is 0. | byte | ||
The registered_delivery that the producer sends with SubmitSm, SubmitMulti, ReplaceSm and DataSm: 0 requests no delivery receipt, 1 a delivery receipt for success and for failure, and 2 a delivery receipt for failure only. The CamelSmppRegisteredDelivery header replaces it; the default is 1. Enum values:
| byte | ||
The replace_if_present_flag that the producer sends with SubmitSm and SubmitMulti: 1 asks the SMSC to replace a message that is still pending delivery and has the same source address, destination address and service type, 0 does not. The CamelSmppReplaceIfPresentFlag header replaces it; the default is 0. Enum values:
| byte | ||
The service_type that the producer sends with SubmitSm, SubmitMulti, CancelSm and DataSm: the SMS application service of the message, such as CMT (cellular messaging), CPT (cellular paging), VMN (voice mail notification), VMA (voice mail alerting), WAP or USSD. Empty by default, for the default service of the SMSC. The CamelSmppServiceType header replaces it. Enum values:
| String | ||
The source address that the producer sends with every command: the address of the SME (Short Message Entity) that sends the message, or, for ReplaceSm, QuerySm and CancelSm, the source address of the original message. The CamelSmppSourceAddr header replaces it. | 1616 | String | |
The numbering plan indicator (NPI) of the source address that the producer sends with every command: 0 unknown, 1 ISDN (E.163/E.164), 2 data (X.121), 3 telex (F.69), 6 land mobile (E.212), 8 national, 9 private, 10 ERMES, 13 Internet (IP) or 18 WAP client id. The CamelSmppSourceAddrNpi header replaces it; the default is 0. Enum values:
| byte | ||
The type of number (TON) of the source address that the producer sends with every command: 0 unknown, 1 international, 2 national, 3 network specific, 4 subscriber number, 5 alphanumeric or 6 abbreviated. The CamelSmppSourceAddrTon header replaces it; the default is 0. Enum values:
| byte | ||
The type of number (TON) that the producer sends in the addr_ton field of its bind request, with the values of the sourceAddrTon option. The consumer binds with 0 (unknown). The default is 0. Enum values:
| byte | ||
Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean | |
A shared SmppConfiguration as the base of the endpoints: each endpoint uses a copy of it, which the options of its URI change. | SmppConfiguration | ||
The time in milliseconds without data from the SMSC after which the session sends an enquire_link to check the connection, or 0 to send none. Camel also uses it as the timeout to connect to the SMSC or the HTTP proxy, and for the TLS handshake. | 60000 | Integer | |
Defines the interface version to be used in the binding request with the SMSC. The following values are allowed, as defined in the SMPP protocol (and the underlying implementation using the jSMPP library, respectively): legacy (0x00), 3.3 (0x33), 3.4 (0x34), and 5.0 (0x50). The default (fallback) value is version 3.4. Enum values:
| 3.4 | String | |
The number of threads of the SMPP session that process the received PDUs in parallel. | 3 | Integer | |
The number of received PDUs that can wait for a free processing thread. When the queue is full, the session answers a received request with the ESME_RTHROTTLED error, so that the SMSC slows down. | 100 | Integer | |
An org.jsmpp.session.SessionStateListener that is notified when the state of the SMPP session of the consumer or producer changes, for example from BOUND_RX to CLOSED. Camel still reconnects a lost session itself. | SessionStateListener | ||
When true, the SMSC delivery receipt would be requested only for the last segment of a multi-segment (long) message. For short messages, with only 1 segment the behaviour is unchanged. | false | boolean | |
The time in milliseconds that the session waits for the response of the SMSC to a request that it sent, such as a submit_sm or an enquire_link, before the request fails. The bind request waits 60 seconds instead. | 10000 | Integer | |
The alphabet in which the producer encodes and splits the text of the short message for SubmitSm, SubmitMulti and ReplaceSm: 0 (the SMSC default alphabet) encodes it in the charset of the encoding option, 8 (UCS2) in UTF-16BE, and 4 (8-bit) sends a byte array body as it is. It does not set the data_coding that is sent, which comes from the dataCoding option. The CamelSmppAlphabet header replaces it; the default is 0. Enum values:
| byte | ||
The data_coding that the producer sends with SubmitSm, SubmitMulti and DataSm, as defined in section 5.2.19 of the SMPP 3.4 specification, for example 0 for the SMSC default alphabet, 3 for Latin 1, 4 for 8-bit binary data and 8 for UCS2. An 8-bit value sends a byte array body as it is; the alphabet and encoding options, not this option, select how a text body is encoded. The CamelSmppDataCoding and CamelSmppAlphabet headers replace it; the default is 0. | byte | ||
The charset in which the producer encodes the text of the short message for SubmitSm, SubmitMulti and ReplaceSm, unless the alphabet is UCS2, and in which the consumer decodes a received message in the SMSC default alphabet. The CamelSmppEncoding header replaces it for the producer. | ISO-8859-1 | String | |
The host name or IP address of an HTTP proxy through which Camel tunnels the SMPP connection, with an HTTP CONNECT request. When not set, Camel connects to the SMSC directly. | String | ||
The password for Basic authentication with the HTTP proxy. It is sent only together with the httpProxyUsername option. | String | ||
The port of the HTTP proxy that the httpProxyHost option sets. | 3128 | Integer | |
The user name for Basic authentication with the HTTP proxy. It is sent only together with the httpProxyPassword option. | String | ||
Extra HTTP headers that Camel sends to the HTTP proxy with the CONNECT request. | Map | ||
Whether a producer with lazySessionCreation=true may take the system id and the password, with which it connects to the SMSC, from the 'CamelSmppSystemId' and 'CamelSmppPassword' headers of the first exchange. When both headers are present, the producer connects with them in place of the systemId and password of the endpoint, and keeps using them when it reconnects. This is disabled by default, and the headers are then ignored. Enable this only when the route sets these headers itself. | false | boolean | |
Whether to check that the certificate of the SMSC matches the host Camel connects to, when SSL is used. When disabled, any certificate trusted by the JVM is accepted, whatever host it was issued for. | true | boolean | |
The password with which the consumer or producer binds to the SMSC. | String | ||
The system_id with which the consumer or producer binds to the SMSC: the user name that the SMSC authenticates. The user info of the URI, as in smpp://userhost, sets it too. | smppclient | String | |
Whether to connect to the SMSC with TLS, which the smpps scheme enables. The certificate of the SMSC must be trusted by the default SSL socket factory of the JVM. Through an HTTP proxy, TLS runs inside the tunnel. | false | boolean |
Endpoint Options
The SMPP endpoint is configured using URI syntax:
smpp:host:port
With the following path and query parameters:
Query Parameters
| Name | Description | Default | Type |
|---|---|---|---|
The delay in milliseconds before the first attempt to reconnect, after the consumer or producer lost its session to the SMSC (the connection was closed, or the SMSC unbound). A failed connect when the consumer or producer starts is not retried. | 5000 | long | |
The maximum number of attempts to reconnect after the session to the SMSC was lost. When the last attempt fails, a consumer stays disconnected until it is restarted, and a producer fails its exchanges, unless lazySessionCreation is enabled, which connects again for the next exchange. | 2147483647 | int | |
The delay in milliseconds between two attempts to reconnect to the SMSC, after the first attempt failed. | 5000 | long | |
What the producer does with a SubmitSm or SubmitMulti whose body does not fit in one short message: ALLOW sends it in several segments, TRUNCATE sends only its first part, and REJECT fails the exchange with an SmppException caused by a NegativeResponseException with status 1. Some carriers drop the segments after the first, which TRUNCATE does not send. The CamelSmppSplittingPolicy header replaces it. Enum values:
| ALLOW | SmppSplittingPolicy | |
The system_type of the bind request, which tells the SMSC the type of ESME (External Short Message Entity) that binds. SMPP 3.4 allows at most 13 octets, the NULL terminator included. Empty by default. | String | ||
The address_range of the bind request of the consumer: the SME addresses that this ESME serves, as defined in section 5.2.7 of the SMPP 3.4 specification. The SMSC uses it to select the messages that it delivers to the consumer. Empty by default. | String | ||
Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean | |
To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | ExceptionHandler | ||
Sets the exchange pattern when the consumer creates an exchange. Enum values:
| ExchangePattern | ||
The destination address that the producer sends with SubmitSm, SubmitMulti, CancelSm and DataSm, for example the phone number of the recipient of a mobile terminated message. The CamelSmppDestAddr header replaces it, with a list of addresses for SubmitMulti. | 1717 | String | |
The numbering plan indicator (NPI) of the destination address that the producer sends with SubmitSm, SubmitMulti, CancelSm and DataSm, with the values of the sourceAddrNpi option. The CamelSmppDestAddrNpi header replaces it; the default is 0. Enum values:
| byte | ||
The type of number (TON) of the destination address that the producer sends with SubmitSm, SubmitMulti, CancelSm and DataSm, with the values of the sourceAddrTon option. The CamelSmppDestAddrTon header replaces it; the default is 0. Enum values:
| byte | ||
Whether the producer connects to the SMSC when it sends its first exchange instead of when it starts, so that the route can start while the SMSC is not available. The producer binds with the systemId and password options, or with headers when allowSystemIdAndPasswordFromHeaders is enabled. | false | boolean | |
The id of a route whose consumer receives the messages that the SMSC sends to this producer. The producer then binds as a transceiver (bind_transceiver) instead of a transmitter, and hands each received deliver_sm, data_sm and alert_notification to that route, so that no SMPP consumer is needed. Only tested with a route that starts from a direct endpoint; the route must exist when Camel starts. | String | ||
The numbering plan indicator (NPI) that the producer sends in the addr_npi field of its bind request, with the values of the sourceAddrNpi option. The consumer binds with 0 (unknown). The default is 0. Enum values:
| byte | ||
The priority_flag that the producer sends with SubmitSm and SubmitMulti, from 0 (lowest) to 3 (highest). The CamelSmppPriorityFlag header replaces it; the default is 1. Enum values:
| byte | ||
The protocol_id that the producer sends with SubmitSm and SubmitMulti, which for GSM is set as defined in GSM 03.40. The CamelSmppProtocolId header replaces it; the default is 0. | byte | ||
The registered_delivery that the producer sends with SubmitSm, SubmitMulti, ReplaceSm and DataSm: 0 requests no delivery receipt, 1 a delivery receipt for success and for failure, and 2 a delivery receipt for failure only. The CamelSmppRegisteredDelivery header replaces it; the default is 1. Enum values:
| byte | ||
The replace_if_present_flag that the producer sends with SubmitSm and SubmitMulti: 1 asks the SMSC to replace a message that is still pending delivery and has the same source address, destination address and service type, 0 does not. The CamelSmppReplaceIfPresentFlag header replaces it; the default is 0. Enum values:
| byte | ||
The service_type that the producer sends with SubmitSm, SubmitMulti, CancelSm and DataSm: the SMS application service of the message, such as CMT (cellular messaging), CPT (cellular paging), VMN (voice mail notification), VMA (voice mail alerting), WAP or USSD. Empty by default, for the default service of the SMSC. The CamelSmppServiceType header replaces it. Enum values:
| String | ||
The source address that the producer sends with every command: the address of the SME (Short Message Entity) that sends the message, or, for ReplaceSm, QuerySm and CancelSm, the source address of the original message. The CamelSmppSourceAddr header replaces it. | 1616 | String | |
The numbering plan indicator (NPI) of the source address that the producer sends with every command: 0 unknown, 1 ISDN (E.163/E.164), 2 data (X.121), 3 telex (F.69), 6 land mobile (E.212), 8 national, 9 private, 10 ERMES, 13 Internet (IP) or 18 WAP client id. The CamelSmppSourceAddrNpi header replaces it; the default is 0. Enum values:
| byte | ||
The type of number (TON) of the source address that the producer sends with every command: 0 unknown, 1 international, 2 national, 3 network specific, 4 subscriber number, 5 alphanumeric or 6 abbreviated. The CamelSmppSourceAddrTon header replaces it; the default is 0. Enum values:
| byte | ||
The type of number (TON) that the producer sends in the addr_ton field of its bind request, with the values of the sourceAddrTon option. The consumer binds with 0 (unknown). The default is 0. Enum values:
| byte | ||
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
The time in milliseconds without data from the SMSC after which the session sends an enquire_link to check the connection, or 0 to send none. Camel also uses it as the timeout to connect to the SMSC or the HTTP proxy, and for the TLS handshake. | 60000 | Integer | |
Defines the interface version to be used in the binding request with the SMSC. The following values are allowed, as defined in the SMPP protocol (and the underlying implementation using the jSMPP library, respectively): legacy (0x00), 3.3 (0x33), 3.4 (0x34), and 5.0 (0x50). The default (fallback) value is version 3.4. Enum values:
| 3.4 | String | |
The number of threads of the SMPP session that process the received PDUs in parallel. | 3 | Integer | |
The number of received PDUs that can wait for a free processing thread. When the queue is full, the session answers a received request with the ESME_RTHROTTLED error, so that the SMSC slows down. | 100 | Integer | |
An org.jsmpp.session.SessionStateListener that is notified when the state of the SMPP session of the consumer or producer changes, for example from BOUND_RX to CLOSED. Camel still reconnects a lost session itself. | SessionStateListener | ||
When true, the SMSC delivery receipt would be requested only for the last segment of a multi-segment (long) message. For short messages, with only 1 segment the behaviour is unchanged. | false | boolean | |
The time in milliseconds that the session waits for the response of the SMSC to a request that it sent, such as a submit_sm or an enquire_link, before the request fails. The bind request waits 60 seconds instead. | 10000 | Integer | |
The alphabet in which the producer encodes and splits the text of the short message for SubmitSm, SubmitMulti and ReplaceSm: 0 (the SMSC default alphabet) encodes it in the charset of the encoding option, 8 (UCS2) in UTF-16BE, and 4 (8-bit) sends a byte array body as it is. It does not set the data_coding that is sent, which comes from the dataCoding option. The CamelSmppAlphabet header replaces it; the default is 0. Enum values:
| byte | ||
The data_coding that the producer sends with SubmitSm, SubmitMulti and DataSm, as defined in section 5.2.19 of the SMPP 3.4 specification, for example 0 for the SMSC default alphabet, 3 for Latin 1, 4 for 8-bit binary data and 8 for UCS2. An 8-bit value sends a byte array body as it is; the alphabet and encoding options, not this option, select how a text body is encoded. The CamelSmppDataCoding and CamelSmppAlphabet headers replace it; the default is 0. | byte | ||
The charset in which the producer encodes the text of the short message for SubmitSm, SubmitMulti and ReplaceSm, unless the alphabet is UCS2, and in which the consumer decodes a received message in the SMSC default alphabet. The CamelSmppEncoding header replaces it for the producer. | ISO-8859-1 | String | |
The host name or IP address of an HTTP proxy through which Camel tunnels the SMPP connection, with an HTTP CONNECT request. When not set, Camel connects to the SMSC directly. | String | ||
The password for Basic authentication with the HTTP proxy. It is sent only together with the httpProxyUsername option. | String | ||
The port of the HTTP proxy that the httpProxyHost option sets. | 3128 | Integer | |
The user name for Basic authentication with the HTTP proxy. It is sent only together with the httpProxyPassword option. | String | ||
Extra HTTP headers that Camel sends to the HTTP proxy with the CONNECT request. | Map | ||
Whether a producer with lazySessionCreation=true may take the system id and the password, with which it connects to the SMSC, from the 'CamelSmppSystemId' and 'CamelSmppPassword' headers of the first exchange. When both headers are present, the producer connects with them in place of the systemId and password of the endpoint, and keeps using them when it reconnects. This is disabled by default, and the headers are then ignored. Enable this only when the route sets these headers itself. | false | boolean | |
Whether to check that the certificate of the SMSC matches the host Camel connects to, when SSL is used. When disabled, any certificate trusted by the JVM is accepted, whatever host it was issued for. | true | boolean | |
The password with which the consumer or producer binds to the SMSC. | String | ||
The system_id with which the consumer or producer binds to the SMSC: the user name that the SMSC authenticates. The user info of the URI, as in smpp://userhost, sets it too. | smppclient | String | |
Whether to connect to the SMSC with TLS, which the smpps scheme enables. The certificate of the SMSC must be trusted by the default SSL socket factory of the JVM. Through an HTTP proxy, TLS runs inside the tunnel. | false | boolean |
Message Headers
The SMPP component supports the following message header(s), which is/are listed below:
| Name | Description | Default | Type |
|---|---|---|---|
| Constant: | The alphabet of the short message, which replaces the alphabet option for SubmitSm, SubmitMulti and ReplaceSm: 0 for the SMSC default alphabet, 4 for 8-bit data and 8 for UCS2. When the CamelSmppDataCoding header is not set, SubmitSm, SubmitMulti and DataSm also send it as the data_coding. | Byte | |
| Constant: | The command to send: SubmitSm (the default when the header is missing), ReplaceSm, QuerySm, SubmitMulti, CancelSm or DataSm. The names are case-sensitive, and any other value fails. | String | |
| Constant: | The command_id of the received PDU, which identifies its type, as listed in section 5.1.2.1 of the SMPP 3.4 specification. Set for an AlertNotification, a DeliverSm and a DataSm. | Integer | |
CamelSmppCommandStatus (consumer) Constant: | The command_status of the received PDU. Set for an AlertNotification and a DataSm. | Integer | |
CamelSmppDataCoding (producer) Constant: | For the producer, the data_coding to send with SubmitSm, SubmitMulti and DataSm, which replaces the dataCoding option; with an 8-bit value, the body is sent as bytes, for ReplaceSm too. The consumer sets it to the data_coding of a received DeliverSm or DataSm. | Byte | |
| Constant: | An org.apache.camel.component.smpp.SmppSplitter that splits the body into segments for SubmitSm and SubmitMulti, instead of the splitter that the producer chooses for the alphabet. A value that is not an SmppSplitter fails the exchange. | SmppSplitter | |
| Constant: | The number of short messages delivered, from the dlvrd field of a delivery receipt. It is relevant only when the original message was submitted to a distribution list. | Integer | |
| Constant: | For the producer, the destination address for SubmitSm, CancelSm and DataSm, or a list of destination addresses for SubmitMulti, which replaces the destAddr option. The consumer sets it to the destination address of a received DeliverSm or DataSm. | List or String | |
| Constant: | For the producer, the numbering plan indicator (NPI) of the destination address for SubmitSm, SubmitMulti, CancelSm and DataSm, which replaces the destAddrNpi option. The consumer sets it to the NPI of the destination address of a received DeliverSm or DataSm. | Byte | |
| Constant: | For the producer, the type of number (TON) of the destination address for SubmitSm, SubmitMulti, CancelSm and DataSm, which replaces the destAddrTon option. The consumer sets it to the TON of the destination address of a received DeliverSm or DataSm. | Byte | |
| Constant: | The date and time at which the message reached its final state, from the done date field of a delivery receipt. | Date | |
| Constant: | The charset in which the producer encodes the text of the body for SubmitSm, SubmitMulti and ReplaceSm, which replaces the encoding option, also for the UCS2 alphabet. A charset that the JVM does not support is logged and ignored. It is not used for an 8-bit message, whose body is sent as bytes: a byte array as it is, any other body converted in the charset of the exchange. | String | |
| Constant: | The producer sets it for SubmitMulti, when some destinations failed, to a map from the message id to a list of maps, each with the destination address (CamelSmppDestAddr key) and the error code (CamelSmppError key); for QuerySm, it sets it to the error_code of the response. The consumer sets it to the err field of a delivery receipt, a network or SMSC specific error code, when it is not 000. | String or Map | |
| Constant: | The esm_class to send with SubmitSm and SubmitMulti. Without it, the producer sends the default esm_class, or the one with the UDH indicator for a message that it splits. | ESMClass | |
| Constant: | The esme_addr of a received AlertNotification: the address of the ESME that requested the alert. | String | |
CamelSmppEsmeAddrNpi (consumer) Constant: | The numbering plan indicator (NPI) of the esme_addr of a received AlertNotification. | Byte | |
CamelSmppEsmeAddrTon (consumer) Constant: | The type of number (TON) of the esme_addr of a received AlertNotification. | Byte | |
| Constant: | The date and time at which the message reached its final state, from the final_date of the response to QuerySm, or null when the message has not reached a final state. | Date | |
| Constant: | The final state of the message, from the stat field of a delivery receipt, such as DELIVRD, UNDELIV or EXPIRED. Enum values:
| DeliveryReceiptState | |
| Constant: | For ReplaceSm, QuerySm and CancelSm, the message id of the message to act on, as the SMSC returned it. After the send, the producer sets it to the list of message ids that the SMSC returned for SubmitSm and SubmitMulti (one per segment), and to a single message id for the other commands. The consumer sets it to the id of the original message for a delivery receipt, and to the message id that it returns to the SMSC for a DataSm. | String or List | |
CamelSmppMessageState (producer) Constant: | The state of the message from the response to QuerySm, as the name of an org.jsmpp.bean.MessageState, such as ENROUTE, DELIVERED or EXPIRED. | String | |
CamelSmppMessageType (consumer) Constant: | Identifies the type of an incoming message: AlertNotification: an SMSC alert notification, DataSm: an SMSC data short message, DeliveryReceipt: an SMSC delivery receipt, DeliverSm: an SMSC deliver short message. | String | |
CamelSmppPriorityFlag (producer) Constant: | The priority_flag to send with SubmitSm and SubmitMulti, from 0 (lowest) to 3 (highest), which replaces the priorityFlag option. | Byte | |
CamelSmppProtocolId (producer) Constant: | The protocol_id to send with SubmitSm and SubmitMulti, which replaces the protocolId option. | Byte | |
CamelSmppRegisteredDelivery (common) Constant: | For the producer, the registered_delivery to send with SubmitSm, SubmitMulti, ReplaceSm and DataSm, which replaces the registeredDelivery option. The consumer sets it to the registered_delivery of a received DataSm. | Byte | |
| Constant: | Whether to request a delivery receipt only for the last segment of a message that is split, for SubmitSm and SubmitMulti, which replaces the singleDLR option. | Boolean | |
CamelSmppReplaceIfPresentFlag (producer) Constant: | The replace_if_present_flag to send with SubmitSm and SubmitMulti, which replaces the replaceIfPresentFlag option: 1 asks the SMSC to replace a message that is still pending delivery and has the same source address, destination address and service type, 0 does not. | Boolean | |
CamelSmppScheduleDeliveryTime (common) Constant: | For the producer, the time at which the SMSC first tries to deliver the message, for SubmitSm, SubmitMulti and ReplaceSm, as a java.util.Date that is sent in the absolute time format of the SMPP 3.4 specification, section 7.1.1. The consumer sets it to the schedule_delivery_time of a received DeliverSm, as the String in that format. | Date | |
CamelSmppSentMessageCount (producer) Constant: | The number of short messages that the producer sent for SubmitSm and SubmitMulti, which is more than one when the body was split. | Integer | |
CamelSmppSequenceNumber (consumer) Constant: | The sequence_number of the received PDU, which correlates the response with the request. Set for an AlertNotification, a DeliverSm and a DataSm. | int | |
| Constant: | For the producer, the service_type to send with SubmitSm, SubmitMulti, CancelSm and DataSm, which replaces the serviceType option. The consumer sets it to the service_type of a received DeliverSm or DataSm. | String | |
| Constant: | For the producer, the source address to send with every command, which replaces the sourceAddr option; for ReplaceSm, QuerySm and CancelSm, the source address of the original message. The consumer sets it to the source address of a received AlertNotification, DeliverSm or DataSm. | String | |
CamelSmppSourceAddrNpi (common) Constant: | For the producer, the numbering plan indicator (NPI) of the source address to send with every command, which replaces the sourceAddrNpi option. The consumer sets it to the NPI of the source address of a received AlertNotification, DeliverSm or DataSm. | Byte | |
CamelSmppSourceAddrTon (common) Constant: | For the producer, the type of number (TON) of the source address to send with every command, which replaces the sourceAddrTon option. The consumer sets it to the TON of the source address of a received AlertNotification, DeliverSm or DataSm. | Byte | |
| Constant: | The number of short messages originally submitted, from the sub field of a delivery receipt. It is relevant only when the original message was submitted to a distribution list. | Integer | |
CamelSmppSubmitDate (consumer) Constant: | The date and time at which the original message was submitted, or replaced, from the submit date field of a delivery receipt. | Date | |
| Constant: | The system id to connect to the SMSC with. Used only by the first exchange of a producer with lazySessionCreation=true and allowSystemIdAndPasswordFromHeaders=true, together with the CamelSmppPassword header; otherwise ignored. | String | |
| Constant: | The password to connect to the SMSC with. Used only by the first exchange of a producer with lazySessionCreation=true and allowSystemIdAndPasswordFromHeaders=true, together with the CamelSmppSystemId header; otherwise ignored. | String | |
CamelSmppValidityPeriod (common) Constant: | For the producer, the time after which the SMSC discards the message if it was not delivered, for SubmitSm, SubmitMulti and ReplaceSm: a java.util.Date is sent in the absolute time format, and a String as it is, so it can hold a relative time (SMPP 3.4 specification, section 7.1.1). The consumer sets it to the validity_period of a received DeliverSm, as a String. | String or Date | |
CamelSmppOptionalParameters (consumer) Constant: | The optional parameters (TLVs) by the name of their org.jsmpp.bean.OptionalParameter.Tag. The producer sends them, with String values, with SubmitSm, SubmitMulti and DataSm when the CamelSmppOptionalParameter header is not set. The consumer sets it for a received DeliverSm, and the producer for the response to DataSm. Deprecation note: Use CamelSmppOptionalParameter instead. | Map | |
CamelSmppOptionalParameter (common) Constant: | The optional parameters (TLVs) by their tag code. The producer sends them with SubmitSm, SubmitMulti and DataSm: a String as a COctetString, a byte array as an OctetString, a Byte, a Short or an Integer as a parameter of that size, and null as a parameter without value; it skips other values. The consumer sets it for a received DeliverSm, and the producer for the response to DataSm, with the values converted back the same way. | Map | |
CamelSmppSplittingPolicy (producer) Constant: | The splitting policy for SubmitSm and SubmitMulti, ALLOW, REJECT or TRUNCATE, which replaces the splittingPolicy option. Any other value fails the exchange. | String |
Message Body
The message body at each side of the SMPP component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.
| Side | Body | Description |
|---|---|---|
Consumer |
| A short message as text decoded by its data coding, or as bytes for an 8-bit data coding; the text of a delivery receipt, with its fields in headers. A data_sm or an alert notification has no body. |
Producer input |
| The text of the short message: bytes, a stream or a file are read as text, unless an 8-bit CamelSmppDataCoding or CamelSmppAlphabet header, or an 8-bit dataCoding or alphabet option for a byte array, sends bytes as they are. A stream is read once and replaced by its content. No body fails; a Map or a POJO is sent as its toString(). DataSm, QuerySm and CancelSm do not read the body. |
Producer output |
| Unchanged, with the message ids in the CamelSmppId header, also when the exchange expects a reply (InOut). |
The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.
Lazy session creation
By default, the producer connects to the SMSC when it starts. With lazySessionCreation=true, it connects when it sends the first message instead, so the route can start while the SMSC is not available.
The producer connects with the systemId and password of the endpoint. To connect with another system id and password chosen by the route, set allowSystemIdAndPasswordFromHeaders=true as well: the producer then takes them from the CamelSmppSystemId and CamelSmppPassword headers of the first message, when both are set, and keeps using them when it reconnects. Without this option, these headers are ignored.
smpp://localhost:2775?lazySessionCreation=true&allowSystemIdAndPasswordFromHeaders=true
Enable allowSystemIdAndPasswordFromHeaders only when the route sets these headers itself, and remove them from messages that come from elsewhere.
Exception handling
This component supports the general Camel exception handling capabilities
When an error occurs sending a message with SubmitSm (the default action), the org.apache.camel.component.smpp.SmppException is thrown with a nested exception, org.jsmpp.extra.NegativeResponseException. Call NegativeResponseException.getCommandStatus() to obtain the exact SMPP negative response code, the values are explained in the SMPP specification 3.4, section 5.1.3.
When the SMPP consumer receives a DeliverSm or DataSm short message and the processing of these messages fails, you can also throw a ProcessRequestException instead of handle the failure. In this case, this exception is forwarded to the underlying JSMPP library which will return the included error code to the SMSC. This feature is useful to e.g., instruct the SMSC to resend the short message at a later time. This could be done with the following lines of code:
from("smpp://smppclient@localhost:2775?password=password&enquireLinkTimer=3000&transactionTimer=5000&systemType=consumer")
.doTry()
.to("bean:dao?method=updateSmsState")
.doCatch(Exception.class)
.throwException(new ProcessRequestException("update of sms state failed", 100))
.end(); Please refer to the SMPP specification for the complete list of error codes and their meanings.
Examples
A route which sends an SMS:
-
Java
-
XML
-
YAML
from("direct:start")
.to("smpp://smppclient@localhost:2775?password=password&enquireLinkTimer=3000&transactionTimer=5000&systemType=producer"); <route>
<from uri="direct:start"/>
<to uri="smpp://smppclient@localhost:2775?password=password&enquireLinkTimer=3000&transactionTimer=5000&systemType=producer"/>
</route> - route:
from:
uri: direct:start
steps:
- to:
uri: smpp://smppclient@localhost:2775
parameters:
password: password
enquireLinkTimer: 3000
transactionTimer: 5000
systemType: producer A route which receives an SMS:
-
Java
-
XML
-
YAML
from("smpp://smppclient@localhost:2775?password=password&enquireLinkTimer=3000&transactionTimer=5000&systemType=consumer")
.to("bean:foo"); <route>
<from uri="smpp://smppclient@localhost:2775?password=password&enquireLinkTimer=3000&transactionTimer=5000&systemType=consumer"/>
<to uri="bean:foo"/>
</route> - route:
from:
uri: smpp://smppclient@localhost:2775
parameters:
password: password
enquireLinkTimer: 3000
transactionTimer: 5000
systemType: consumer
steps:
- to:
uri: bean:foo An example of using transceiver (TRX) binding type:
from("direct:start")
.to("smpp://j@localhost:8056?password=jpwd&systemType=producer" +
"&messageReceiverRouteId=sampleMessageReceiverRouteId");
from("direct:messageReceiver").id("sampleMessageReceiverRouteId")
.to("bean:foo"); Please note that with TRX binding type, you wouldn’t define a corresponding redundant SMPP consumer. Camel will use the specified route by messageReceiverRouteId as the corresponding consumer. Internally, it uses one and same SmppSession as producer for the provided consumer.
When the SMPP Server doesn’t support TRX, then you have to define separate producer (TX by default) and consumer (RX by default).
| SMSC simulator If you need an SMSC simulator for your test, you can use the simulator provided by JSMPP. |