I am using JSMPP (Java implementation of SMPP) for sending SMS from my web application to SMS center. I have the following code to receive the delivery report of any sent SMS.
public class MessageListenerImplementation implements MessageReceiverListener {
public void onAcceptDeliverSm(DeliverSm deliverSm) throws ProcessRequestException {
if (MessageType.SMSC_DEL_RECEIPT.containedIn(deliverSm.getEsmClass())) {
try {
DeliveryReceipt deliveryReceipt = deliverSm.getShortMessageAsDeliveryReceipt();
long id = Long.parseLong(deliveryReceipt.getId()) & 0xffffffff;
String messageId = Long.toString(id, 16).toUpperCase();
System.out.println("Delivery receipt for message '" + messageId + " ' from " + deliverSm.getSourceAddr() + " to " + deliverSm.getDestAddress() + " : " + deliveryReceipt);
}catch (InvalidDeliveryReceiptException e) {
System.err.println("Failed getting delivery receipt");
e.printStackTrace();
}
}
}
}
When I register the above listener for an SMS' delivery receipt and send it, it get the delivery receipt as follows
and the delivery receipt is as follows
id:5 sub:001 dlvrd:001 submit date:1312091213 done date:1312091213 stat:DELIVRD err:000 text:Hello SMSC from ESME
Now I am wondering how to retrieve the sending status in some integer range that whether it is sent,failed or still pending so that I can use it to update my database accordingly ?
There is DeliveryReceiptState enumaration in Jsmpp for the all delivery status codes. Try
deliveryReceipt.getFinalStatus().value()
which will you give you integer value to update in database.You will get following integer values for status codes.