use of org.restcomm.smpp.EsmeManagement in project smscgateway by RestComm.
the class SubmitCommonSbb method forwardMessage.
protected void forwardMessage(Sms sms0, boolean withCharging, SmscStatAggregator smscStatAggregator, String messageType, int seqNumber) throws SmscProcessingException {
ChargingMedium chargingMedium = null;
EventType eventTypeFailure = null;
int statusCode = 0;
switch(sms0.getOriginationType()) {
case SMPP:
chargingMedium = ChargingMedium.TxSmppOrig;
eventTypeFailure = EventType.IN_SMPP_REJECT_MPROC;
break;
case SS7_MO:
case SS7_HR:
chargingMedium = ChargingMedium.MoOrig;
break;
case SIP:
chargingMedium = ChargingMedium.TxSipOrig;
break;
case HTTP:
chargingMedium = ChargingMedium.HttpOrig;
eventTypeFailure = EventType.IN_HTTP_REJECT_MPROC;
break;
}
if (withCharging) {
ChargingSbbLocalObject chargingSbb = getChargingSbbObject();
chargingSbb.setupChargingRequestInterface(chargingMedium, sms0);
} else {
// applying of MProc
MProcResult mProcResult = MProcManagement.getInstance().applyMProcArrival(itsMProcRa, sms0, persistence);
FastList<Sms> smss = mProcResult.getMessageList();
if (smss != null) {
for (FastList.Node<Sms> n = smss.head(), end = smss.tail(); (n = n.getNext()) != end; ) {
Sms sms = n.getValue();
TargetAddress ta = new TargetAddress(sms.getSmsSet());
TargetAddress lock = persistence.obtainSynchroObject(ta);
try {
sms.setTimestampC(System.currentTimeMillis());
synchronized (lock) {
boolean storeAndForwMode = MessageUtil.isStoreAndForward(sms);
if (!storeAndForwMode) {
try {
this.scheduler.injectSmsOnFly(sms.getSmsSet(), true);
} catch (Exception e) {
throw new SmscProcessingException("Exception when running injectSmsOnFly(): " + e.getMessage(), SmppConstants.STATUS_SYSERR, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e, SmscProcessingException.INTERNAL_ERROR_INJECT_STORE_AND_FORWARD_NOT_SET);
}
} else {
// store and forward
if (smscPropertiesManagement.getStoreAndForwordMode() == StoreAndForwordMode.fast && sms.getScheduleDeliveryTime() == null) {
try {
sms.setStoringAfterFailure(true);
this.scheduler.injectSmsOnFly(sms.getSmsSet(), true);
} catch (Exception e) {
throw new SmscProcessingException("Exception when running injectSmsOnFly(): " + e.getMessage(), SmppConstants.STATUS_SYSERR, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e, SmscProcessingException.INTERNAL_ERROR_INJECT_STORE_AND_FORWARD_FAST);
}
} else {
try {
sms.setStored(true);
this.scheduler.setDestCluster(sms.getSmsSet());
persistence.c2_scheduleMessage_ReschedDueSlot(sms, smscPropertiesManagement.getStoreAndForwordMode() == StoreAndForwordMode.fast, false);
} catch (PersistenceException e) {
throw new SmscProcessingException("PersistenceException when storing LIVE_SMS : " + e.getMessage(), SmppConstants.STATUS_SUBMITFAIL, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e, SmscProcessingException.INTERNAL_ERROR_INJECT_STORE_AND_FORWARD_NORMAL);
}
}
}
}
} finally {
persistence.releaseSynchroObject(lock);
}
}
}
if (mProcResult.isMessageRejected()) {
sms0.setMessageDeliveryResultResponse(null);
if (eventTypeFailure != null) {
String sourceAddrAndPort = null;
if (eventTypeFailure == EventType.IN_SMPP_REJECT_MPROC) {
EsmeManagement esmeManagement = EsmeManagement.getInstance();
if (esmeManagement != null) {
// for testing there is no EsmeManagement
Esme esme = esmeManagement.getEsmeByClusterName(sms0.getOrigEsmeName());
// null check is for testing
if (esme != null) {
sourceAddrAndPort = esme.getRemoteAddressAndPort();
}
}
statusCode = mProcResult.getSmppErrorCode();
} else if (eventTypeFailure == EventType.IN_HTTP_REJECT_MPROC) {
statusCode = mProcResult.getHttpErrorCode();
}
generateMprocFailureDetailedCdr(sms0, eventTypeFailure, ErrorCode.REJECT_INCOMING_MPROC, messageType, statusCode, mProcResult.getRuleIdDropReject(), sourceAddrAndPort, seqNumber);
}
rejectSmsByMProc(sms0, "Message is rejected by MProc rules.", mProcResult);
}
if (mProcResult.isMessageDropped()) {
sms0.setMessageDeliveryResultResponse(null);
smscStatAggregator.updateMsgInFailedAll();
if (eventTypeFailure != null) {
String sourceAddrAndPort = null;
if (eventTypeFailure == EventType.IN_SMPP_REJECT_MPROC) {
eventTypeFailure = EventType.IN_SMPP_DROP_MPROC;
EsmeManagement esmeManagement = EsmeManagement.getInstance();
if (esmeManagement != null) {
// for testing there is no EsmeManagement
Esme esme = esmeManagement.getEsmeByClusterName(sms0.getOrigEsmeName());
// null check is for testing
if (esme != null) {
sourceAddrAndPort = esme.getRemoteAddressAndPort();
}
}
statusCode = mProcResult.getSmppErrorCode();
} else if (eventTypeFailure == EventType.IN_HTTP_REJECT_MPROC) {
eventTypeFailure = EventType.IN_HTTP_DROP_MPROC;
statusCode = mProcResult.getHttpErrorCode();
}
generateMprocFailureDetailedCdr(sms0, eventTypeFailure, ErrorCode.REJECT_INCOMING_MPROC, messageType, statusCode, mProcResult.getRuleIdDropReject(), sourceAddrAndPort, seqNumber);
}
rejectSmsByMProc(sms0, "Message is dropped by MProc rules.", mProcResult);
}
smscStatAggregator.updateMsgInReceivedAll();
switch(sms0.getOriginationType()) {
case SMPP:
smscStatAggregator.updateMsgInReceivedSmpp();
break;
case SS7_MO:
smscStatAggregator.updateMsgInReceivedSs7();
smscStatAggregator.updateMsgInReceivedSs7Mo();
break;
case SS7_HR:
smscStatAggregator.updateMsgInReceivedSs7();
smscStatAggregator.updateMsgInReceivedSs7Hr();
break;
case SIP:
smscStatAggregator.updateMsgInReceivedSip();
break;
}
}
}
use of org.restcomm.smpp.EsmeManagement in project smscgateway by RestComm.
the class RxSmppServerSbb method handleResponse.
/**
* Processing of a positive delivery response to smpp destination.
*
* @param event
* @throws Exception
*/
private void handleResponse(BaseSmResp event) throws Exception {
long ts = System.currentTimeMillis();
if (isDeliveringEnded()) {
if (logger.isFineEnabled()) {
this.logger.fine("SMPP Response received when DeliveringEnded state: status=" + event.getCommandStatus());
}
}
if (isDeliveringEnded()) {
logger.info("RxSmppServerSbb.handleResponse(): received submit/deliver_sm_response but delivery process is already ended, dropping of a response");
return;
}
SmsSet smsSet = getSmsSet();
if (smsSet == null) {
logger.severe("RxSmppServerSbb.handleResponse(): CMP smsSet is missed");
markDeliveringIsEnded(true);
return;
}
int status = event.getCommandStatus();
if (status == 0) {
smscStatAggregator.updateMsgOutSentAll();
smscStatAggregator.updateMsgOutSentSmpp();
boolean destAddressLimitationEnabled = false;
EsmeManagement esmeManagement = EsmeManagement.getInstance();
Esme esme = esmeManagement.getEsmeByClusterName(smsSet.getDestClusterName());
if (esme != null) {
destAddressLimitationEnabled = esme.getDestAddrSendLimit() != 0;
}
int realID = -1;
Boolean sentListChanged = false;
SentItemsList list = null;
if (destAddressLimitationEnabled) {
list = retreiveSentChunks();
for (int i = 0; i < list.getSentList().size(); i++) {
if (list.getSentList().get(i).getRemoteSequenceNumber() == event.getSequenceNumber()) {
realID = list.getSentList().get(i).getLocalSequenceNumber();
list.getSentList().remove(i);
sentListChanged = true;
break;
}
}
} else {
realID = event.getSequenceNumber();
}
ConfirmMessageInSendingPool confirmMessageInSendingPool = null;
if (realID != -1)
confirmMessageInSendingPool = confirmMessageInSendingPool(realID);
if (realID == -1 || !confirmMessageInSendingPool.sequenceNumberFound) {
this.logger.severe("RxSmppServerSbb.handleResponse(): no sms in MessageInSendingPool: UnconfirmedCnt=" + this.getUnconfirmedMessageCountInSendingPool() + ", sequenceNumber=" + event.getSequenceNumber() + ", realID=" + realID + ", confirmMessageInSendingPool=" + confirmMessageInSendingPool);
this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SC_SYSTEM_ERROR, "Received undefined SequenceNumber: " + event.getSequenceNumber() + ", SmsSet=" + smsSet, EventType.OUT_SMPP_ERROR, realID);
if (sentListChanged)
setSentChunks(list);
return;
}
Sms sms = confirmMessageInSendingPool.sms;
if (sms != null) {
sms.setTimestampC(System.currentTimeMillis());
}
if (destAddressLimitationEnabled) {
ChunkDataList dataList = retreivePendingChunks();
if (dataList != null && !dataList.getPendingList().isEmpty()) {
// so checking if has window
if (list.getSentList().size() < esme.getDestAddrSendLimit()) {
ChunkData current = dataList.getPendingList().remove(0);
setPendingChunks(dataList);
if (current != null) {
SentItem newItem = sendNextChunk(current, smsSet, esme);
SentItemsList sentChunks = retreiveSentChunks();
sentChunks.getSentList().add(newItem);
sentListChanged = true;
}
}
}
}
if (sentListChanged)
setSentChunks(list);
if (!confirmMessageInSendingPool.confirmed) {
this.generateCDR(sms, CdrGenerator.CDR_PARTIAL_ESME, CdrGenerator.CDR_SUCCESS_NO_REASON, true, false, event.getSequenceNumber());
String messageType = esme.getSmppSessionType() == Type.CLIENT ? CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM : CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM;
this.generateDetailedCDR(sms, EventType.OUT_SMPP_SENT, sms.getSmsSet().getStatus(), messageType, status, esme.getRemoteAddressAndPort(), event.getSequenceNumber());
return;
}
// firstly we store remote messageId if sms has a request to delivery receipt
String clusterName = smsSet.getDestClusterName();
String dlvMessageId = event.getMessageId();
sms.setDlvMessageId(dlvMessageId);
// if (MessageUtil.isDeliveryReceiptRequest(sms)) {
// SmsSetCache.getInstance().putDeliveredRemoteMsgIdValue(dlvMessageId, clusterName, sms.getMessageId(), 30);
// }
// current message is sent
// firstly sending of a positive response for transactional mode
sendTransactionalResponseSuccess(sms);
// mproc rules applying for delivery phase
this.applyMprocRulesOnSuccess(sms, ProcessingType.SMPP);
// Processing succeeded
sms.getSmsSet().setStatus(ErrorCode.SUCCESS);
this.postProcessSucceeded(sms, dlvMessageId, clusterName);
// success CDR generating
boolean isPartial = MessageUtil.isSmsNotLastSegment(sms);
this.generateCDR(sms, isPartial ? CdrGenerator.CDR_PARTIAL_ESME : CdrGenerator.CDR_SUCCESS_ESME, CdrGenerator.CDR_SUCCESS_NO_REASON, confirmMessageInSendingPool.splittedMessage, true, event.getSequenceNumber());
String messageType = null;
String remoteAddr = null;
if (esme != null) {
messageType = esme.getSmppSessionType() == Type.CLIENT ? CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM : CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM;
remoteAddr = esme.getRemoteAddressAndPort();
}
if (messageType == null) {
if (event.getCommandId() == SmppConstants.CMD_ID_DELIVER_SM_RESP) {
messageType = CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM;
} else {
messageType = CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM;
}
}
this.generateDetailedCDR(sms, EventType.OUT_SMPP_SENT, sms.getSmsSet().getStatus(), messageType, status, remoteAddr, event.getSequenceNumber());
// adding a success receipt if it is needed
this.generateSuccessReceipt(smsSet, sms);
if (this.getUnconfirmedMessageCountInSendingPool() == 0) {
// all sent messages are confirmed - we are sending new message set
TargetAddress lock = persistence.obtainSynchroObject(new TargetAddress(smsSet));
try {
synchronized (lock) {
// marking the message in cache as delivered
this.commitSendingPoolMsgCount();
ts = warnIfLong(logger, ts, "handleResponse/status=0/in-lock/commitSendingPoolMsgCount");
// now we are trying to sent other messages
if (this.getTotalUnsentMessageCount() > 0) {
try {
this.sendDeliverSm(smsSet);
ts = warnIfLong(logger, ts, "handleResponse/status=0/in-lock/sendDeliverSm");
return;
} catch (SmscProcessingException e) {
SbbStatsUtils.handleProcessingException(e, getDefaultSbbUsageParameterSet());
String s = "SmscProcessingException when sending next sendDeliverSm()=" + e.getMessage() + ", Message=" + sms;
logger.severe(s, e);
this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SC_SYSTEM_ERROR, s, EventType.OUT_SMPP_ERROR, event.getSequenceNumber());
}
}
// no more messages to send - remove smsSet
smsSet.setStatus(ErrorCode.SUCCESS);
this.markDeliveringIsEnded(true);
}
} finally {
persistence.releaseSynchroObject(lock);
}
}
} else {
ErrorAction errorAction = ErrorAction.permanentFailure;
smsSet.setSmppCommandStatus(status);
if (status == SmppConstants.STATUS_THROTTLED || status == SmppConstants.STATUS_X_T_APPN || status == SmppConstants.STATUS_SYSERR || status == SmppConstants.STATUS_INVBNDSTS || status == SmppConstants.STATUS_MSGQFUL)
errorAction = ErrorAction.temporaryFailure;
logger.warning("RxSmppServerSbb.handleResponse(): error code response received: status=" + status + ", errorAction=" + errorAction + ", smsSet=" + smsSet);
this.onDeliveryError(smsSet, errorAction, ErrorCode.SC_SYSTEM_ERROR, event.getName() + " has a bad status: " + status, EventType.OUT_SMPP_REJECTED, event.getSequenceNumber());
}
}
use of org.restcomm.smpp.EsmeManagement in project smscgateway by RestComm.
the class DeliveryCommonSbb method endDeliveryAfterValidityPeriod.
/**
* Finishing delivering of a message which validity period is over at the start of delivery time.
*
* @param sms
* @param processingType
* @param dlvMessageId
* @param dlvDestId
*/
protected void endDeliveryAfterValidityPeriod(Sms sms, ProcessingType processingType, String dlvMessageId, String dlvDestId) {
// ending of delivery process in this SBB
ErrorCode smStatus = ErrorCode.VALIDITY_PERIOD_EXPIRED;
ErrorAction errorAction = ErrorAction.permanentFailure;
String reason = "Validity period is expired";
smsSet.setStatus(smStatus);
StringBuilder sb = new StringBuilder();
sb.append("onDeliveryError: errorAction=validityExpired");
sb.append(", smStatus=");
sb.append(smStatus);
sb.append(", targetId=");
sb.append(smsSet.getTargetId());
sb.append(", smsSet=");
sb.append(smsSet);
sb.append(", reason=");
sb.append(reason);
if (this.logger.isInfoEnabled())
this.logger.info(sb.toString());
// mproc rules applying for delivery phase
MProcResult mProcResult = MProcManagement.getInstance().applyMProcDelivery(itsMProcRa, sms, true, processingType);
if (mProcResult.isMessageIsRerouted()) {
// we do not reroute a message with expired validity period
sb = new StringBuilder();
sb.append("Can not reroute of a message with expired ValidityPeriod, sms=");
sb.append(sms);
this.logger.warning(sb.toString());
}
FastList<Sms> addedMessages = mProcResult.getMessageList();
if (addedMessages != null) {
for (FastList.Node<Sms> n = addedMessages.head(), end = addedMessages.tail(); (n = n.getNext()) != end; ) {
Sms smst = n.getValue();
TargetAddress ta = new TargetAddress(smst.getSmsSet().getDestAddrTon(), smst.getSmsSet().getDestAddrNpi(), smst.getSmsSet().getDestAddr(), smst.getSmsSet().getNetworkId());
this.sendNewGeneratedMessage(smst, ta);
if (this.logger.isInfoEnabled()) {
sb = new StringBuilder();
sb.append("Posting of a new message after PermFailure-ValidityPeriod: targetId=");
sb.append(smst.getSmsSet().getTargetId());
sb.append(", sms=");
sb.append(smst);
this.logger.info(sb.toString());
}
}
}
ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
lstPermFailured.add(sms);
// sending of a failure response for transactional mode
this.sendTransactionalResponseFailure(lstPermFailured, null, errorAction, null);
// Processing messages that were temp or permanent failed or rerouted
this.postProcessPermFailures(lstPermFailured, dlvMessageId, dlvDestId);
// generating CDRs for permanent failure messages
this.generateCDRs(lstPermFailured, CdrGenerator.CDR_FAILED, reason);
EsmeManagement esmeManagement = EsmeManagement.getInstance();
if (esmeManagement != null) {
Esme esme = null;
if (smsSet.getDestClusterName() != null) {
esme = esmeManagement.getEsmeByClusterName(smsSet.getDestClusterName());
}
String messageType = null;
String remoteAddr = null;
if (esme != null) {
messageType = esme.getSmppSessionType() == Type.CLIENT ? CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM : CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM;
remoteAddr = esme.getRemoteAddressAndPort();
}
this.generateDetailedCDRs(lstPermFailured, EventType.VALIDITY_PERIOD_TIMEOUT, smStatus, messageType, remoteAddr, -1);
}
// sending of failure delivery receipts
this.generateFailureReceipts(smsSet, lstPermFailured, null);
}
use of org.restcomm.smpp.EsmeManagement in project smscgateway by RestComm.
the class ChargingSbb method rejectSmsByMproc.
private void rejectSmsByMproc(ChargingData chargingData, boolean isRejected) throws SmscProcessingException {
Sms sms = chargingData.getSms();
if (logger.isInfoEnabled()) {
logger.info("ChargingSbb: incoming message is " + (isRejected ? "rejected" : "dropped") + " by mProc rules, message=[" + sms + "]");
}
CdrGenerator.generateCdr(sms, (isRejected ? CdrGenerator.CDR_MPROC_REJECTED : CdrGenerator.CDR_MPROC_DROPPED), "Message is rejected by MProc rules.", smscPropertiesManagement.getGenerateReceiptCdr(), MessageUtil.isNeedWriteArchiveMessage(sms, smscPropertiesManagement.getGenerateCdr()), false, true, smscPropertiesManagement.getCalculateMsgPartsLenCdr(), smscPropertiesManagement.getDelayParametersInCdr());
try {
// sending of a failure response for transactional mode / delaying for charging result
MessageDeliveryResultResponseInterface.DeliveryFailureReason delReason = MessageDeliveryResultResponseInterface.DeliveryFailureReason.invalidDestinationAddress;
if (sms.getMessageDeliveryResultResponse() != null) {
if (isRejected) {
sms.getMessageDeliveryResultResponse().responseDeliveryFailure(delReason, null);
sms.setMessageDeliveryResultResponse(null);
} else {
sms.getMessageDeliveryResultResponse().responseDeliverySuccess();
sms.setMessageDeliveryResultResponse(null);
}
}
sms.getSmsSet().setStatus(ErrorCode.MPROC_ACCESS_NOT_GRANTED);
boolean storeAndForwMode = MessageUtil.isStoreAndForward(sms);
if (storeAndForwMode) {
sms.setStored(true);
}
// if (smscPropertiesManagement.getDatabaseType() == DatabaseType.Cassandra_1) {
// persistence.archiveFailuredSms(sms);
// } else {
String sourceAddrAndPort = null;
String messageType = null;
EventType eventType = null;
switch(sms.getOriginationType()) {
case SMPP:
EsmeManagement esmeManagement = EsmeManagement.getInstance();
Esme esme = esmeManagement.getEsmeByClusterName(sms.getSmsSet().getDestClusterName());
eventType = EventType.IN_SMPP_REJECT_MPROC;
if (esme != null) {
sourceAddrAndPort = esme.getRemoteAddressAndPort();
// shouldn't have null value
messageType = esme.getSmppSessionType() == Type.CLIENT ? CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM : CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM;
}
break;
case HTTP:
messageType = CdrDetailedGenerator.CDR_MSG_TYPE_HTTP;
eventType = EventType.IN_HTTP_REJECT_MPROC;
break;
default:
break;
}
if (eventType != null) {
CdrDetailedGenerator.generateDetailedCdr(sms, eventType, sms.getSmsSet().getStatus(), messageType, 0, -1, sourceAddrAndPort, null, -1, smscPropertiesManagement.getGenerateReceiptCdr(), smscPropertiesManagement.getGenerateDetailedCdr());
}
if (MessageUtil.isNeedWriteArchiveMessage(sms, smscPropertiesManagement.getGenerateArchiveTable())) {
persistence.c2_createRecordArchive(sms, null, null, !smscPropertiesManagement.getReceiptsDisabling(), smscPropertiesManagement.getIncomeReceiptsProcessing());
}
// }
smscStatAggregator.updateMsgInRejectedAll();
CdrGenerator.generateCdr(sms, (isRejected ? CdrGenerator.CDR_MPROC_REJECTED : CdrGenerator.CDR_MPROC_DROPPED), CdrGenerator.CDR_SUCCESS_NO_REASON, smscPropertiesManagement.getGenerateReceiptCdr(), MessageUtil.isNeedWriteArchiveMessage(sms, smscPropertiesManagement.getGenerateCdr()), false, true, smscPropertiesManagement.getCalculateMsgPartsLenCdr(), smscPropertiesManagement.getDelayParametersInCdr());
} catch (PersistenceException e) {
throw new SmscProcessingException("PersistenceException when storing into Archive rejected by MProc message : " + e.getMessage(), SmppConstants.STATUS_SUBMITFAIL, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e);
}
}
use of org.restcomm.smpp.EsmeManagement in project smscgateway by RestComm.
the class ChargingSbb method acceptSms.
private void acceptSms(ChargingData chargingData) throws SmscProcessingException {
Sms sms0 = chargingData.getSms();
if (logger.isInfoEnabled()) {
logger.info("ChargingSbb: accessGranted for: chargingType=" + chargingData.getChargingType() + ", message=[" + sms0 + "]");
}
try {
MProcResult mProcResult = MProcManagement.getInstance().applyMProcArrival(itsMProcRa, sms0, persistence);
FastList<Sms> smss = mProcResult.getMessageList();
if (smss != null) {
for (FastList.Node<Sms> n = smss.head(), end = smss.tail(); (n = n.getNext()) != end; ) {
Sms sms = n.getValue();
TargetAddress ta = new TargetAddress(sms.getSmsSet());
TargetAddress lock = persistence.obtainSynchroObject(ta);
sms.setTimestampC(System.currentTimeMillis());
try {
synchronized (lock) {
boolean storeAndForwMode = MessageUtil.isStoreAndForward(sms);
if (!storeAndForwMode) {
try {
this.scheduler.injectSmsOnFly(sms.getSmsSet(), true);
} catch (Exception e) {
throw new SmscProcessingException("Exception when runnung injectSmsOnFly(): " + e.getMessage(), SmppConstants.STATUS_SYSERR, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e);
}
} else {
if (smscPropertiesManagement.getStoreAndForwordMode() == StoreAndForwordMode.fast) {
try {
sms.setStoringAfterFailure(true);
this.scheduler.injectSmsOnFly(sms.getSmsSet(), true);
} catch (Exception e) {
throw new SmscProcessingException("Exception when runnung injectSmsOnFly(): " + e.getMessage(), SmppConstants.STATUS_SYSERR, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e);
}
} else {
sms.setStored(true);
// if (smscPropertiesManagement.getDatabaseType() == DatabaseType.Cassandra_1) {
// persistence.createLiveSms(sms);
// persistence.setNewMessageScheduled(sms.getSmsSet(),
// MessageUtil.computeDueDate(MessageUtil.computeFirstDueDelay(smscPropertiesManagement.getFirstDueDelay())));
// } else {
this.scheduler.setDestCluster(sms.getSmsSet());
persistence.c2_scheduleMessage_ReschedDueSlot(sms, smscPropertiesManagement.getStoreAndForwordMode() == StoreAndForwordMode.fast, false);
// }
}
}
}
} finally {
persistence.releaseSynchroObject(lock);
}
}
}
if (mProcResult.isMessageRejected()) {
rejectSmsByMproc(chargingData, true);
return;
}
if (mProcResult.isMessageDropped()) {
rejectSmsByMproc(chargingData, false);
return;
}
// sending success response for charging result
if (sms0.getMessageDeliveryResultResponse() != null && sms0.getMessageDeliveryResultResponse().isOnlyChargingRequest()) {
sms0.getMessageDeliveryResultResponse().responseDeliverySuccess();
sms0.setTimestampB(System.currentTimeMillis());
EventType eventTypeSuccess = null;
String messageType = null;
String sourceAddr = null;
int seqNum = -1;
switch(sms0.getOriginationType()) {
case SMPP:
eventTypeSuccess = EventType.IN_SMPP_RECEIVED;
MessageDeliveryResultResponseInterface resp = sms0.getMessageDeliveryResultResponse();
messageType = resp.getMessageType();
seqNum = resp.getSeqNumber();
break;
case HTTP:
eventTypeSuccess = EventType.IN_HTTP_RECEIVED;
messageType = CdrDetailedGenerator.CDR_MSG_TYPE_HTTP;
break;
default:
break;
}
if (eventTypeSuccess != null) {
EsmeManagement esmeManagement = EsmeManagement.getInstance();
if (esmeManagement != null) {
// for testing there is no EsmeManagement
Esme esme = esmeManagement.getEsmeByClusterName(sms0.getOrigEsmeName());
// null check is for testing
if (esme != null) {
sourceAddr = esme.getRemoteAddressAndPort();
}
}
CdrDetailedGenerator.generateDetailedCdr(sms0, eventTypeSuccess, sms0.getSmsSet().getStatus(), messageType, SmppConstants.STATUS_OK, -1, sourceAddr, null, seqNum, smscPropertiesManagement.getGenerateReceiptCdr(), smscPropertiesManagement.getGenerateDetailedCdr());
}
sms0.setMessageDeliveryResultResponse(null);
}
smscStatAggregator.updateMsgInReceivedAll();
switch(sms0.getOriginationType()) {
case SMPP:
smscStatAggregator.updateMsgInReceivedSmpp();
break;
case SS7_MO:
smscStatAggregator.updateMsgInReceivedSs7();
smscStatAggregator.updateMsgInReceivedSs7Mo();
break;
case SS7_HR:
smscStatAggregator.updateMsgInReceivedSs7();
smscStatAggregator.updateMsgInReceivedSs7Hr();
break;
case SIP:
smscStatAggregator.updateMsgInReceivedSip();
break;
default:
break;
}
} catch (PersistenceException e) {
if (sms0 != null) {
generateCDR(sms0, CdrGenerator.CDR_SUBMIT_FAILED_CHARGING, e.getMessage(), false, true);
}
throw new SmscProcessingException("PersistenceException when storing LIVE_SMS : " + e.getMessage(), SmppConstants.STATUS_SUBMITFAIL, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e);
}
}
Aggregations