use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class DeliveryCommonSbb method obtainNextMessagesSendingPool.
/**
* Arrange a new message sending pool with the poolMessageCount message count in it. If pending message count is less then
* poolMessageCount then all pending message will be arranged to a message sending pool. Previous arranging pool will be
* removed by this operation and pending messages in it will be marked as already processed. If you need to arrange only one
* message in message sending pool you can use obtainNextMessage() method. Messages wit expired ValidityPeriod are not added
* to a sendingPoolMsg but are processed as perm failed.
*
* @param poolMessageCount Max message count that must be included into a a new message sending pool
* @param processingType
* @return a count of messages in a new message pool
*/
protected int obtainNextMessagesSendingPool(int poolMessageCount, ProcessingType processingType) {
commitSendingPoolMsgCount();
if (smsSet != null) {
int addedMessageCnt = 0;
TargetAddress lock = persistence.obtainSynchroObject(new TargetAddress(smsSet));
// ***** lock ******
try {
synchronized (lock) {
int gotMessageCnt = 0;
int sendingPoolMsgCount = this.getTotalUnsentMessageCount();
for (int i1 = 0; i1 < sendingPoolMsgCount; i1++) {
if (addedMessageCnt >= poolMessageCount) {
break;
}
gotMessageCnt++;
Sms sms = smsSet.getSms(currentMsgNum + i1);
if (sms == null) {
this.logger.severe("RxSmpp obtainNextMessagesSendingPool() error: sms is not found num=" + i1 + " from " + sendingPoolMsgCount + ", smsSet=" + smsSet, new Throwable());
break;
}
if (sms.getValidityPeriod() != null && sms.getValidityPeriod().getTime() <= System.currentTimeMillis()) {
this.endDeliveryAfterValidityPeriod(sms, processingType, null, null);
} else {
boolean res1 = applyMProcPreDelivery(sms, processingType);
if (res1) {
addedMessageCnt++;
sms.setDeliveryCount(sms.getDeliveryCount() + 1);
smsSet.markSmsAsDelivered(currentMsgNum + i1);
smsSet.addMessageToSendingPool(sms);
}
}
}
sequenceNumbers = new int[addedMessageCnt];
sequenceNumbersExtra = new int[addedMessageCnt][];
if (gotMessageCnt > 0) {
currentMsgNum += gotMessageCnt;
this.setCurrentMsgNum(currentMsgNum);
}
this.rescheduleDeliveryTimer(sendingPoolMsgCount);
}
} finally {
persistence.releaseSynchroObject(lock);
}
return addedMessageCnt;
} else
return 0;
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class DeliveryCommonSbb method generateTemporaryFailureDetailedCDR.
protected void generateTemporaryFailureDetailedCDR(EventType eventType, String messageType, ErrorCode errorCode, String destAddrAndPort, int seqNumber) {
int sendingPoolMessageCount = this.getSendingPoolMessageCount();
for (int i1 = 0; i1 < sendingPoolMessageCount; i1++) {
if (!this.isMessageConfirmedInSendingPool(i1)) {
Sms sms = this.getMessageInSendingPool(i1);
if (sms != null) {
CdrDetailedGenerator.generateDetailedCdr(sms, eventType, errorCode, messageType, sms.getSmsSet().getSmppCommandStatus(), -1, null, destAddrAndPort, seqNumber, smscPropertiesManagement.getGenerateReceiptCdr(), smscPropertiesManagement.getGenerateDetailedCdr());
return;
}
}
}
// if no message was sent in a message pool, let's
// ***** no lock ******
Sms sms = this.getUnsentMessage(0);
if (sms != null) {
CdrDetailedGenerator.generateDetailedCdr(sms, eventType, errorCode, messageType, sms.getSmsSet().getSmppCommandStatus(), -1, null, destAddrAndPort, seqNumber, smscPropertiesManagement.getGenerateReceiptCdr(), smscPropertiesManagement.getGenerateDetailedCdr());
return;
}
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class DeliveryCommonSbb method generateSuccessReceipt.
// *********
// delivery receipts generating
/**
* Generating of a success receipt for a delivered message
*
* @param smsSet
* @param sms
*/
protected void generateSuccessReceipt(SmsSet smsSet, Sms sms) {
if (!smscPropertiesManagement.getReceiptsDisabling()) {
// SMPP delivery receipt
int registeredDelivery = sms.getRegisteredDelivery();
if (MessageUtil.isReceiptOnSuccess(registeredDelivery)) {
TargetAddress ta = new TargetAddress(sms.getSourceAddrTon(), sms.getSourceAddrNpi(), sms.getSourceAddr(), smsSet.getNetworkId());
Sms receipt = MessageUtil.createReceiptSms(sms, true, ta, smscPropertiesManagement.getOrigNetworkIdForReceipts());
this.sendNewGeneratedMessage(receipt, ta);
}
// SMS-STATUS-REPORT
if (sms.isStatusReportRequest()) {
TargetAddress ta = new TargetAddress(sms.getSourceAddrTon(), sms.getSourceAddrNpi(), sms.getSourceAddr(), smsSet.getNetworkId());
Sms smsStatusReport = MessageUtil.createSmsStatusReport(sms, true, ta, smscPropertiesManagement.getOrigNetworkIdForReceipts());
this.sendNewGeneratedMessage(smsStatusReport, ta);
}
}
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class DeliveryCommonSbb method generateFailureReceipts.
/**
* Generating of failure receipts for permanent failed messages
*
* @param smsSet
* @param lstPermFailured
*/
protected void generateFailureReceipts(SmsSet smsSet, ArrayList<Sms> lstPermFailured, String extraString) {
if (!smscPropertiesManagement.getReceiptsDisabling()) {
for (Sms sms : lstPermFailured) {
// SMPP delivery receipt
int registeredDelivery = sms.getRegisteredDelivery();
if (MessageUtil.isReceiptOnFailure(registeredDelivery)) {
TargetAddress ta = new TargetAddress(sms.getSourceAddrTon(), sms.getSourceAddrNpi(), sms.getSourceAddr(), smsSet.getNetworkId());
Sms receipt = MessageUtil.createReceiptSms(sms, false, ta, smscPropertiesManagement.getOrigNetworkIdForReceipts(), extraString);
this.sendNewGeneratedMessage(receipt, ta);
this.logger.info("Adding an failire receipt: source=" + receipt.getSourceAddr() + ", dest=" + receipt.getSmsSet().getDestAddr());
}
// SMS-STATUS-REPORT
if (sms.isStatusReportRequest()) {
TargetAddress ta = new TargetAddress(sms.getSourceAddrTon(), sms.getSourceAddrNpi(), sms.getSourceAddr(), smsSet.getNetworkId());
Sms smsStatusReport = MessageUtil.createSmsStatusReport(sms, false, ta, smscPropertiesManagement.getOrigNetworkIdForReceipts());
this.sendNewGeneratedMessage(smsStatusReport, ta);
this.logger.info("Adding an failire SMS-STATUS-REPORT: source=" + smsStatusReport.getSourceAddr() + ", dest=" + smsStatusReport.getSmsSet().getDestAddr());
}
}
}
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class DeliveryCommonSbb method createFailureLists.
// *********
// creating of permanent and temporary failure lists for processing after delivery success or failure
/**
* Put of unsent messages into a permanent failure list (no more delivery attempts) or a temporary failure list (more
* delivery attempts are possible).
*
* @param lstPermFailured
* @param lstTempFailured
* @param newDueTime
*/
protected void createFailureLists(ArrayList<Sms> lstPermFailured, ArrayList<Sms> lstTempFailured, ErrorAction errorAction, Date newDueTime) {
// unsent messages in SendingPool
int sendingPoolMessageCount = this.getSendingPoolMessageCount();
for (int i1 = 0; i1 < sendingPoolMessageCount; i1++) {
if (!this.isMessageConfirmedInSendingPool(i1)) {
Sms sms = this.getMessageInSendingPool(i1);
if (sms != null) {
doCreateFailureLists(lstPermFailured, lstTempFailured, sms, errorAction, newDueTime);
}
}
}
// marking messages in SendingPool as sent
this.commitSendingPoolMsgCount();
// unsent messages outside a message pool
int totalUnsentMessageCount = this.getTotalUnsentMessageCount();
for (int i1 = 0; i1 < totalUnsentMessageCount; i1++) {
Sms sms = this.getUnsentMessage(i1);
if (sms != null) {
doCreateFailureLists(lstPermFailured, lstTempFailured, sms, errorAction, newDueTime);
}
}
}
Aggregations