use of org.mobicents.smsc.library.SmscProcessingException in project smscgateway by RestComm.
the class RxSmppServerSbb method sendDeliverSm.
// *********
// Main service methods
/**
* Sending of a set of messages after initial message or when all sent messages was sent
*
* @param smsSet
* @throws SmscProcessingException
*/
private void sendDeliverSm(SmsSet smsSet) throws SmscProcessingException {
try {
int deliveryMsgCnt = this.obtainNextMessagesSendingPool(maxMessagesPerStep, ProcessingType.SMPP);
if (deliveryMsgCnt == 0) {
this.markDeliveringIsEnded(true);
return;
}
EsmeManagement esmeManagement = EsmeManagement.getInstance();
Esme esme = esmeManagement.getEsmeByClusterName(smsSet.getDestClusterName());
if (esme == null) {
String s = "RxSmppServerSbb.sendDeliverSm(): Received DELIVER_SM SmsEvent but no Esme found for destClusterName: " + smsSet.getDestClusterName() + ", smsSet=" + smsSet;
logger.warning(s);
this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SC_SYSTEM_ERROR, s, EventType.OUT_SMPP_ERROR, -1);
return;
}
smsSet.setDestSystemId(esme.getSystemId());
smsSet.setDestEsmeName(esme.getName());
List<ChunkData> pendingMessages = new ArrayList<ChunkData>();
boolean destAddressLimitationEnabled = esme.getDestAddrSendLimit() != 0;
for (int poolIndex = 0; poolIndex < deliveryMsgCnt; poolIndex++) {
smscStatAggregator.updateMsgOutTryAll();
smscStatAggregator.updateMsgOutTrySmpp();
Sms sms = this.getMessageInSendingPool(poolIndex);
if (sms == null) {
// this should not be
throw new SmscProcessingException("sendDeliverSm: getCurrentMessage() returns null sms for msgNum in SendingPool " + poolIndex, 0, 0, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, SmscProcessingException.INTERNAL_ERROR_SEND_DELIVER_SM_000007);
}
sms.setTimestampA(System.currentTimeMillis());
// message splitting staff
boolean esmeAllowSplitting = esme.getSplitLongMessages();
int esmClass = sms.getEsmClass();
boolean udhPresent = (esmClass & SmppConstants.ESM_CLASS_UDHI_MASK) != 0;
Tlv sarMsgRefNum = sms.getTlvSet().getOptionalParameter(SmppConstants.TAG_SAR_MSG_REF_NUM);
Tlv sarTotalSegments = sms.getTlvSet().getOptionalParameter(SmppConstants.TAG_SAR_TOTAL_SEGMENTS);
Tlv sarSegmentSeqnum = sms.getTlvSet().getOptionalParameter(SmppConstants.TAG_SAR_SEGMENT_SEQNUM);
boolean sarTlvPresent = sarMsgRefNum != null && sarTotalSegments != null && sarSegmentSeqnum != null;
ArrayList<String> lstStrings = new ArrayList<String>();
ArrayList<byte[]> lstUdhs = new ArrayList<byte[]>();
lstStrings.add(sms.getShortMessageText());
lstUdhs.add(sms.getShortMessageBin());
if (esmeAllowSplitting && !udhPresent && !sarTlvPresent) {
DataCodingScheme dataCodingScheme = this.mapSmsTpduParameterFactory.createDataCodingScheme(sms.getDataCoding());
String[] segmentsStrings = MessageUtil.sliceMessage(sms.getShortMessageText(), dataCodingScheme, sms.getNationalLanguageLockingShift(), sms.getNationalLanguageSingleShift());
if (segmentsStrings != null && segmentsStrings.length > 1) {
// we need to split a message for segments
lstStrings.clear();
lstUdhs.clear();
int messageReferenceNumber = getNextMessageReferenceNumber();
esmClass |= SmppConstants.ESM_CLASS_UDHI_MASK;
int messageSegmentCount = segmentsStrings.length;
for (int ii1 = 0; ii1 < messageSegmentCount; ii1++) {
lstStrings.add(segmentsStrings[ii1]);
byte[] bf1 = new byte[7];
// total UDH length
bf1[0] = 6;
// UDH id
bf1[1] = UserDataHeader._InformationElementIdentifier_ConcatenatedShortMessages16bit;
// UDH length
bf1[2] = 4;
bf1[3] = (byte) (messageReferenceNumber & 0x00FF);
bf1[4] = (byte) ((messageReferenceNumber & 0xFF00) >> 8);
// segmCnt
bf1[5] = (byte) messageSegmentCount;
// segmNum
bf1[6] = (byte) (ii1 + 1);
lstUdhs.add(bf1);
}
}
}
int sequenceNumber = 0;
int[] sequenceNumberExt = null;
int segmCnt = lstStrings.size();
if (segmCnt > 1) {
sequenceNumberExt = new int[segmCnt - 1];
}
for (int segmentIndex = 0; segmentIndex < segmCnt; segmentIndex++) {
if (esme.getSmppSessionType() == Type.CLIENT) {
SubmitSm submitSm = new SubmitSm();
submitSm.setSourceAddress(new Address((byte) sms.getSourceAddrTon(), (byte) sms.getSourceAddrNpi(), sms.getSourceAddr()));
submitSm.setDestAddress(new Address((byte) sms.getSmsSet().getDestAddrTon(), (byte) sms.getSmsSet().getDestAddrNpi(), sms.getSmsSet().getDestAddr()));
submitSm.setEsmClass((byte) esmClass);
submitSm.setProtocolId((byte) sms.getProtocolId());
submitSm.setPriority((byte) sms.getPriority());
if (sms.getScheduleDeliveryTime() != null) {
submitSm.setScheduleDeliveryTime(MessageUtil.printSmppAbsoluteDate(sms.getScheduleDeliveryTime(), -(new Date()).getTimezoneOffset()));
}
if (sms.getValidityPeriod() != null) {
submitSm.setValidityPeriod(MessageUtil.printSmppAbsoluteDate(sms.getValidityPeriod(), -(new Date()).getTimezoneOffset()));
}
submitSm.setRegisteredDelivery((byte) sms.getRegisteredDelivery());
submitSm.setReplaceIfPresent((byte) sms.getReplaceIfPresent());
submitSm.setDataCoding((byte) sms.getDataCoding());
String msgStr = lstStrings.get(segmentIndex);
byte[] msgUdh = lstUdhs.get(segmentIndex);
if (msgStr != null || msgUdh != null) {
byte[] msg = recodeShortMessage(sms.getDataCoding(), msgStr, msgUdh);
if (msg.length <= 255) {
submitSm.setShortMessage(msg);
} else {
Tlv tlv = new Tlv(SmppConstants.TAG_MESSAGE_PAYLOAD, msg, null);
submitSm.addOptionalParameter(tlv);
}
}
for (Tlv tlv : sms.getTlvSet().getOptionalParameters()) {
submitSm.addOptionalParameter(tlv);
}
int currLocalSequenceNumber = getLastLocalSequenceNumber();
if (currLocalSequenceNumber == Integer.MAX_VALUE)
setLastLocalSequenceNumber(0);
else
setLastLocalSequenceNumber(currLocalSequenceNumber + 1);
ChunkData currData = new ChunkData(submitSm, currLocalSequenceNumber);
int sentSequenceNumber = currData.getLocalSequenceNumber();
if (destAddressLimitationEnabled) {
pendingMessages.add(currData);
} else {
SentItem sentItem = sendNextChunk(currData, smsSet, esme);
long t = System.currentTimeMillis();
sms.setTimestampB(t);
sentSequenceNumber = sentItem.getRemoteSequenceNumber();
sms.putMsgPartDeliveryTime(sentSequenceNumber, t);
}
if (logger.isInfoEnabled()) {
logger.info(String.format("Sent submitSm to ESME: %s, msgNumInSendingPool: %d, sms=%s", esme.getName(), poolIndex, sms.toString()));
}
if (segmentIndex == 0) {
sequenceNumber = sentSequenceNumber;
} else {
sequenceNumberExt[segmentIndex - 1] = sentSequenceNumber;
}
} else {
DeliverSm deliverSm = new DeliverSm();
deliverSm.setSourceAddress(new Address((byte) sms.getSourceAddrTon(), (byte) sms.getSourceAddrNpi(), sms.getSourceAddr()));
deliverSm.setDestAddress(new Address((byte) sms.getSmsSet().getDestAddrTon(), (byte) sms.getSmsSet().getDestAddrNpi(), sms.getSmsSet().getDestAddr()));
deliverSm.setEsmClass((byte) esmClass);
deliverSm.setProtocolId((byte) sms.getProtocolId());
deliverSm.setPriority((byte) sms.getPriority());
if (sms.getScheduleDeliveryTime() != null) {
deliverSm.setScheduleDeliveryTime(MessageUtil.printSmppAbsoluteDate(sms.getScheduleDeliveryTime(), -(new Date()).getTimezoneOffset()));
}
if (sms.getValidityPeriod() != null && esme.getSmppVersion() == SmppInterfaceVersionType.SMPP50) {
deliverSm.setValidityPeriod(MessageUtil.printSmppAbsoluteDate(sms.getValidityPeriod(), -(new Date()).getTimezoneOffset()));
}
deliverSm.setRegisteredDelivery((byte) sms.getRegisteredDelivery());
deliverSm.setReplaceIfPresent((byte) sms.getReplaceIfPresent());
deliverSm.setDataCoding((byte) sms.getDataCoding());
String msgStr = lstStrings.get(segmentIndex);
byte[] msgUdh = lstUdhs.get(segmentIndex);
if (msgStr != null || msgUdh != null) {
byte[] msg = recodeShortMessage(sms.getDataCoding(), msgStr, msgUdh);
if (msg.length <= 255) {
deliverSm.setShortMessage(msg);
} else {
Tlv tlv = new Tlv(SmppConstants.TAG_MESSAGE_PAYLOAD, msg, null);
deliverSm.addOptionalParameter(tlv);
}
}
for (Tlv tlv : sms.getTlvSet().getOptionalParameters()) {
deliverSm.addOptionalParameter(tlv);
}
// TODO : waiting for 2 secs for window to accept our
// request,
// is it good? Should time be more here?
int currLocalSequenceNumber = getLastLocalSequenceNumber();
if (currLocalSequenceNumber == Integer.MAX_VALUE)
setLastLocalSequenceNumber(0);
else
setLastLocalSequenceNumber(currLocalSequenceNumber + 1);
ChunkData currData = new ChunkData(deliverSm, currLocalSequenceNumber);
int sentSequenceNumber = currData.getLocalSequenceNumber();
if (destAddressLimitationEnabled) {
pendingMessages.add(currData);
} else {
SentItem sentItem = sendNextChunk(currData, smsSet, esme);
long t = System.currentTimeMillis();
sms.setTimestampB(t);
sentSequenceNumber = sentItem.getRemoteSequenceNumber();
sms.putMsgPartDeliveryTime(sentSequenceNumber, t);
}
if (logger.isInfoEnabled()) {
logger.info(String.format("Sent deliverSm to ESME: %s, msgNumInSendingPool: %d, sms=%s", esme.getName(), poolIndex, sms.toString()));
}
if (segmentIndex == 0) {
sequenceNumber = sentSequenceNumber;
} else {
sequenceNumberExt[segmentIndex - 1] = sentSequenceNumber;
}
}
}
this.registerMessageInSendingPool(poolIndex, sequenceNumber, sequenceNumberExt);
}
this.endRegisterMessageInSendingPool();
if (destAddressLimitationEnabled) {
ChunkDataList pendingChunks = retreivePendingChunks();
pendingChunks.getPendingList().addAll(pendingMessages);
SentItemsList sentChunks = retreiveSentChunks();
int pdusToSendSize = pendingChunks.getPendingList().size();
int allowedSendWindowSize = esme.getDestAddrSendLimit() - sentChunks.getSentList().size();
if (allowedSendWindowSize < pdusToSendSize)
pdusToSendSize = allowedSendWindowSize;
List<ChunkData> pdusToSend = new ArrayList<ChunkData>();
for (int i = 0; i < pdusToSendSize; i++) {
pdusToSend.add(pendingChunks.getPendingList().remove(0));
}
setPendingChunks(pendingChunks);
ArrayList<SentItem> sentResults = new ArrayList<SentItem>();
while (pdusToSend.size() > 0) {
SentItem result = sendNextChunk(pdusToSend.remove(0), smsSet, esme);
if (result != null)
sentResults.add(result);
}
if (!sentResults.isEmpty()) {
sentChunks.getSentList().addAll(sentResults);
setSentChunks(sentChunks);
}
}
} catch (Throwable e) {
throw new SmscProcessingException("RxSmppServerSbb.sendDeliverSm(): Exception while trying to send DELIVERY Report for received SmsEvent=" + e.getMessage() + "smsSet: " + smsSet, 0, 0, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e, SmscProcessingException.INTERNAL_ERROR_SEND_DELIVER_SM_000008);
}
}
use of org.mobicents.smsc.library.SmscProcessingException 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.mobicents.smsc.library.SmscProcessingException 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.mobicents.smsc.library.SmscProcessingException in project smscgateway by RestComm.
the class RxSmppServerSbb method onDeliverSmLocal.
private void onDeliverSmLocal(final RxSmppServerSbbUsage anSbbUsage, final SmsSetEvent event) {
try {
if (this.logger.isFineEnabled()) {
this.logger.fine("Received Deliver SMS. event= " + event + "this=" + this);
}
SmsSet smsSet = event.getSmsSet();
this.addInitialMessageSet(smsSet);
try {
this.sendDeliverSm(smsSet);
} catch (SmscProcessingException e) {
String s = "SmscProcessingException when sending initial sendDeliverSm()=" + e.getMessage() + ", smsSet=" + smsSet;
logger.severe(s, e);
this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SC_SYSTEM_ERROR, s, EventType.OUT_SMPP_ERROR, -1);
}
} catch (Throwable e1) {
anSbbUsage.incrementCounterErrorDeliverSm(ONE);
logger.severe("Exception in RxSmppServerSbb.onDeliverSm() when fetching records and issuing events: " + e1.getMessage(), e1);
markDeliveringIsEnded(true);
}
}
use of org.mobicents.smsc.library.SmscProcessingException in project smscgateway by RestComm.
the class MtSbb method onDialogReject.
@Override
public void onDialogReject(DialogReject evt, ActivityContextInterface aci) {
try {
SmsSet smsSet = getSmsSet();
if (smsSet == null) {
logger.severe("MtSbb.onDialogReject(): CMP smsSet is missed");
markDeliveringIsEnded(true);
return;
}
MAPRefuseReason mapRefuseReason = evt.getRefuseReason();
if (mapRefuseReason == MAPRefuseReason.PotentialVersionIncompatibility && evt.getMAPDialog().getApplicationContext().getApplicationContextVersion() != MAPApplicationContextVersion.version1) {
if (logger.isWarningEnabled()) {
this.logger.warning("Rx : Mt onDialogReject / PotentialVersionIncompatibility=" + evt);
}
MAPApplicationContextVersion newMAPApplicationContextVersion = MAPApplicationContextVersion.version1;
if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
// If version1 already tried this is error
String reason = "Error condition when invoking sendMtSms() from onDialogReject()." + newMAPApplicationContextVersion + " already tried and DialogReject again suggests Version1";
this.logger.severe(reason);
ErrorCode smStatus = ErrorCode.MAP_SERVER_VERSION_ERROR;
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
}
this.setNegotiatedMapVersionUsing(false);
this.setMAPVersionTested(newMAPApplicationContextVersion);
mapVersionCache.setMAPApplicationContextVersion(this.getNetworkNode().getGlobalTitle().getDigits(), newMAPApplicationContextVersion);
// Now send new ForwardSM with supported ACN (MAP V1)
try {
// Update cache
this.sendMtSms(this.getMtFoSMSMAPApplicationContext(MAPApplicationContextVersion.version1), MessageProcessingState.resendAfterMapProtocolNegotiation, null, smsSet.getNetworkId());
return;
} catch (SmscProcessingException e) {
String reason = "SmscPocessingException when invoking sendMtSms() from onDialogReject()-resendAfterMapProtocolNegotiation: " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
try {
smStatus = ErrorCode.fromInt(e.getSmppErrorCode());
} catch (IllegalArgumentException e1) {
}
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
} catch (Throwable e) {
String reason = "Exception when invoking sendMtSms() from onDialogReject()-resendAfterMapProtocolNegotiation: " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
}
}
// If ACN not supported, lets use the new one suggested
if (mapRefuseReason == MAPRefuseReason.ApplicationContextNotSupported) {
String nodeDigits = this.getNetworkNode().getGlobalTitle().getDigits();
if (logger.isWarningEnabled()) {
this.logger.warning("Rx : Mt onDialogReject / ApplicationContextNotSupported for node " + nodeDigits + " Event=" + evt);
}
// Now send new MtSMS with supported ACN
ApplicationContextName tcapApplicationContextName = evt.getAlternativeApplicationContext();
MAPApplicationContext supportedMAPApplicationContext = MAPApplicationContext.getInstance(tcapApplicationContextName.getOid());
MAPApplicationContextVersion supportedMAPApplicationContextVersion = supportedMAPApplicationContext.getApplicationContextVersion();
MAPApplicationContextVersion newMAPApplicationContextVersion = supportedMAPApplicationContextVersion;
if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
newMAPApplicationContextVersion = MAPApplicationContextVersion.version3;
if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
newMAPApplicationContextVersion = MAPApplicationContextVersion.version2;
if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
newMAPApplicationContextVersion = MAPApplicationContextVersion.version1;
if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
// If all versions are already tried this is
// error
String reason = "Error condition when invoking sendMtSms() from onDialogReject()." + " all MAP versions are already tried and DialogReject again suggests Version1";
this.logger.severe(reason);
ErrorCode smStatus = ErrorCode.MAP_SERVER_VERSION_ERROR;
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
}
}
}
}
this.setNegotiatedMapVersionUsing(false);
this.setMAPVersionTested(newMAPApplicationContextVersion);
mapVersionCache.setMAPApplicationContextVersion(this.getNetworkNode().getGlobalTitle().getDigits(), newMAPApplicationContextVersion);
try {
this.sendMtSms(this.getMtFoSMSMAPApplicationContext(newMAPApplicationContextVersion), MessageProcessingState.resendAfterMapProtocolNegotiation, null, smsSet.getNetworkId());
return;
} catch (SmscProcessingException e) {
String reason = "SmscPocessingException when invoking sendMtSms() from onDialogReject()-resendAfterMapProtocolNegotiation: " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
try {
smStatus = ErrorCode.fromInt(e.getSmppErrorCode());
} catch (IllegalArgumentException e1) {
}
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
} catch (Throwable e) {
String reason = "Exception when invoking sendMtSms() from onDialogReject()-resendAfterMapProtocolNegotiation: " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
}
}
super.onDialogReject(evt, aci);
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.MSC_REFUSES_SM, "onDialogReject after MT Request: " + mapRefuseReason != null ? mapRefuseReason.toString() : "", true, null, false, ProcessingType.SS7_MT);
} catch (Throwable e1) {
logger.severe("Exception in MtSbb.onDialogReject() when fetching records and issuing events: " + e1.getMessage(), e1);
markDeliveringIsEnded(true);
}
}
Aggregations