use of org.restcomm.smpp.EsmeManagement in project smscgateway by RestComm.
the class ChargingSbb method rejectSmsByDiameter.
private void rejectSmsByDiameter(ChargingData chargingData, RoCreditControlAnswer evt) throws SmscProcessingException {
Sms sms = chargingData.getSms();
if (logger.isInfoEnabled()) {
logger.info("ChargingSbb: accessRejected for: resultCode =" + (evt != null ? evt.getResultCode() : "timeout") + ", chargingType=" + chargingData.getChargingType() + ", message=[" + sms + "]");
}
try {
// sending of a failure response for transactional mode / delaying for charging result
MessageDeliveryResultResponseInterface.DeliveryFailureReason delReason = MessageDeliveryResultResponseInterface.DeliveryFailureReason.invalidDestinationAddress;
if (sms.getMessageDeliveryResultResponse() != null) {
sms.getMessageDeliveryResultResponse().responseDeliveryFailure(delReason, null);
sms.setMessageDeliveryResultResponse(null);
}
sms.getSmsSet().setStatus(ErrorCode.OCS_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 = null;
if (esmeManagement != null)
esme = esmeManagement.getEsmeByClusterName(sms.getOrigEsmeName());
eventType = EventType.IN_SMPP_REJECT_DIAMETER;
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_DIAMETER;
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();
// TODO: if CCR gives some response verbal reject reason
// we need replace CdrGenerator.CDR_SUCCESS_NO_REASON with this
// reason
CdrGenerator.generateCdr(sms, CdrGenerator.CDR_OCS_REJECTED, 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 OCS 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 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 = "\nRxSmppServerSbb.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("\nSent 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("\nSent 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() + "\nsmsSet: " + smsSet, 0, 0, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e, SmscProcessingException.INTERNAL_ERROR_SEND_DELIVER_SM_000008);
}
}
use of org.restcomm.smpp.EsmeManagement in project smscgateway by RestComm.
the class RxSmppServerSbb method onSendPduStatusLocal.
private void onSendPduStatusLocal(final SendPduStatus event, final ActivityContextInterface aci) {
if (logger.isFineEnabled())
logger.fine("onSendPduStatusParent - refire to RxSmppServerChildSbb : activity=" + aci.getActivity());
RxSmppServerChildLocalObject rxSmppServerSbbLocalObject = this.getRxSmppServerChildSbbObject();
if (rxSmppServerSbbLocalObject != null) {
ActivityContextInterface act = getSchedulerActivityContextInterface();
if (act != null) {
try {
act.attach(rxSmppServerSbbLocalObject);
SendPduStatus2 event2 = new SendPduStatus2(event.getException(), event.getRequest(), event.getResponse(), event.getSystemId(), event.isSuccess());
SmsSet smsSet = getSmsSet();
Pdu pduEvent = event.getRequest();
if (event.getResponse() != null)
pduEvent = event.getResponse();
EsmeManagement esmeManagement = EsmeManagement.getInstance();
Boolean destAddressLimitationEnabled = false;
if (esmeManagement != null && smsSet != null) {
Esme esme = esmeManagement.getEsmeByName(smsSet.getDestEsmeName());
if (esme != null) {
destAddressLimitationEnabled = esme.getDestAddrSendLimit() != 0;
}
}
int realID = -1;
SentItemsList list = null;
if (destAddressLimitationEnabled) {
list = retreiveSentChunks();
for (int i = 0; i < list.getSentList().size(); i++) {
if (list.getSentList().get(i).getRemoteSequenceNumber() == pduEvent.getSequenceNumber()) {
realID = list.getSentList().get(i).getLocalSequenceNumber();
break;
}
}
} else {
realID = pduEvent.getSequenceNumber();
}
ConfirmMessageInSendingPool confirmMessageInSendingPool = null;
if (realID != -1)
confirmMessageInSendingPool = getMessageInSendingPoolBySeqNumber(realID);
fireSendPduStatusChild(event2, act, null);
} catch (IllegalStateException e) {
if (logger.isInfoEnabled())
logger.info("onSendPduStatus - IllegalStateException (activity is ending - dropping a SLEE event because it is not needed) : new activity=" + act.getActivity() + ", event=" + event);
}
}
}
}
use of org.restcomm.smpp.EsmeManagement in project smscgateway by RestComm.
the class RxSmppServerSbb method onDeliveryError.
/**
* Processing a case when an error in message sending process. This stops of message sending, reschedule or drop messages
* and clear resources.
*
* @param smsSet
* @param errorAction
* @param smStatus
* @param reason
*/
private void onDeliveryError(SmsSet smsSet, ErrorAction errorAction, ErrorCode smStatus, String reason, EventType eventType, int seqNumber) {
getDefaultSbbUsageParameterSet().incrementCounterErrorDelivery(ONE);
try {
smscStatAggregator.updateMsgOutFailedAll();
EsmeManagement esmeManagement = EsmeManagement.getInstance();
Esme 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();
}
// generating of a temporary failure CDR (one record for all unsent messages)
if (smscPropertiesManagement.getGenerateTempFailureCdr()) {
this.generateTemporaryFailureCDR(CdrGenerator.CDR_TEMP_FAILED_ESME, reason);
this.generateTemporaryFailureDetailedCDR(eventType, messageType, smStatus, remoteAddr, seqNumber);
}
ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
ArrayList<Sms> lstTempFailured = new ArrayList<Sms>();
ArrayList<Sms> lstPermFailured2 = new ArrayList<Sms>();
ArrayList<Sms> lstTempFailured2 = new ArrayList<Sms>();
ArrayList<Sms> lstRerouted = new ArrayList<Sms>();
ArrayList<Integer> lstNewNetworkId = new ArrayList<Integer>();
TargetAddress lock = persistence.obtainSynchroObject(new TargetAddress(smsSet));
synchronized (lock) {
try {
setPendingChunks(null);
setSentChunks(null);
// ending of delivery process in this SBB
smsSet.setStatus(smStatus);
this.markDeliveringIsEnded(true);
// calculating of newDueDelay and NewDueTime
int newDueDelay = calculateNewDueDelay(smsSet, false);
Date newDueTime = calculateNewDueTime(smsSet, newDueDelay);
// creating of failure lists
this.createFailureLists(lstPermFailured, lstTempFailured, errorAction, newDueTime);
// mproc rules applying for delivery phase
this.applyMprocRulesOnFailure(lstPermFailured, lstTempFailured, lstPermFailured2, lstTempFailured2, lstRerouted, lstNewNetworkId, ProcessingType.SMPP);
// sending of a failure response for transactional mode
this.sendTransactionalResponseFailure(lstPermFailured2, lstTempFailured2, errorAction, null);
// Processing messages that were temp or permanent failed or rerouted
this.postProcessPermFailures(lstPermFailured2, null, null);
this.postProcessTempFailures(smsSet, lstTempFailured2, newDueDelay, newDueTime, false);
this.postProcessRerouted(lstRerouted, lstNewNetworkId);
// generating CDRs for permanent failure messages
this.generateCDRs(lstPermFailured2, CdrGenerator.CDR_FAILED_ESME, reason);
if (!smscPropertiesManagement.getGenerateTempFailureCdr()) {
generateDetailedCDRs(lstPermFailured2, EventType.OUT_SMPP_ERROR, smStatus, messageType, remoteAddr, seqNumber);
}
// sending of intermediate delivery receipts
this.generateIntermediateReceipts(smsSet, lstTempFailured2);
// sending of failure delivery receipts
this.generateFailureReceipts(smsSet, lstPermFailured2, null);
} finally {
persistence.releaseSynchroObject(lock);
}
}
} catch (Throwable e) {
getDefaultSbbUsageParameterSet().incrementCounterErrorDeliveryException(ONE);
logger.severe("Exception in RxSmppServerSbb.onDeliveryError(): " + e.getMessage(), e);
markDeliveringIsEnded(true);
}
}
use of org.restcomm.smpp.EsmeManagement in project smscgateway by RestComm.
the class DeliveryCommonSbb method applyMProcPreDelivery.
private boolean applyMProcPreDelivery(Sms sms, ProcessingType processingType) {
MProcResult mProcResult = MProcManagement.getInstance().applyMProcPreDelivery(itsMProcRa, sms, processingType);
if (mProcResult.isMessageIsRerouted()) {
// firstly we check if rerouting attempts was not too many
if (sms.getReroutingCount() >= MAX_POSSIBLE_REROUTING) {
StringBuilder sb = new StringBuilder();
sb.append("Rerouting message attempt in PreDelivery, but we have already rerouted ");
sb.append(MAX_POSSIBLE_REROUTING);
sb.append(" times before: targetId=");
sb.append(sms.getSmsSet().getTargetId());
sb.append(", newNetworkId=");
sb.append(mProcResult.getNewNetworkId());
sb.append(", sms=");
sb.append(sms);
this.logger.warning(sb.toString());
return false;
} else if (mProcResult.getNewNetworkId() == sms.getSmsSet().getNetworkId()) {
// we do not reroute for the same networkId
return true;
} else {
ArrayList<Sms> lstRerouted = new ArrayList<Sms>();
ArrayList<Integer> lstNewNetworkId = new ArrayList<Integer>();
lstRerouted.add(sms);
lstNewNetworkId.add(mProcResult.getNewNetworkId());
if (this.logger.isInfoEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("Rerouting message in PreDelivery: targetId=");
sb.append(sms.getSmsSet().getTargetId());
sb.append(", newNetworkId=");
sb.append(mProcResult.getNewNetworkId());
sb.append(", sms=");
sb.append(sms);
this.logger.info(sb.toString());
}
postProcessRerouted(lstRerouted, lstNewNetworkId);
return false;
}
} else if (mProcResult.isMessageDropped()) {
if (this.logger.isInfoEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("Dropping message after in PreDelivery: targetId=");
sb.append(sms.getSmsSet().getTargetId());
sb.append(", sms=");
sb.append(sms);
this.logger.info(sb.toString());
}
ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
lstPermFailured.add(sms);
ErrorCode smStatus = ErrorCode.MPROC_PRE_DELIVERY_DROP;
ErrorAction errorAction = ErrorAction.permanentFailure;
String reason = "Message drop in PreDelivery";
sms.getSmsSet().setStatus(smStatus);
// 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, null, null);
// generating CDRs for permanent failure messages
this.generateCDRs(lstPermFailured, CdrGenerator.CDR_MPROC_DROP_PRE_DELIVERY, reason);
EsmeManagement esmeManagement = EsmeManagement.getInstance();
Esme esme = esmeManagement.getEsmeByClusterName(smsSet.getDestClusterName());
String messageType = esme.getSmppSessionType() == Type.CLIENT ? CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM : CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM;
this.generateDetailedCDRs(lstPermFailured, EventType.OUT_SMPP_ERROR, smStatus, messageType, esme.getRemoteAddressAndPort(), -1);
// sending of failure delivery receipts
this.generateFailureReceipts(sms.getSmsSet(), lstPermFailured, null);
return false;
}
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()) {
StringBuilder sb = new StringBuilder();
sb.append("Posting of a new message after PreDelivery: targetId=");
sb.append(smst.getSmsSet().getTargetId());
sb.append(", sms=");
sb.append(smst);
this.logger.info(sb.toString());
}
}
}
return true;
}
Aggregations