Search in sources :

Example 1 with ErrorAction

use of org.mobicents.smsc.library.ErrorAction in project smscgateway by RestComm.

the class MtSbb method onErrorComponent.

// *********
// MAP Component events
@Override
public void onErrorComponent(ErrorComponent event, ActivityContextInterface aci) {
    try {
        super.onErrorComponent(event, aci);
        SmsSet smsSet = getSmsSet();
        if (smsSet == null) {
            logger.severe("MtSbb.onErrorComponent(): CMP smsSet is missed");
            return;
        }
        MAPErrorMessage mapErrorMessage = event.getMAPErrorMessage();
        if (mapErrorMessage.isEmSubscriberBusyForMtSms()) {
            MAPErrorMessageSubscriberBusyForMtSms subscriberBusyForMtSms = mapErrorMessage.getEmSubscriberBusyForMtSms();
            this.onDeliveryError(smsSet, ErrorAction.subscriberBusy, ErrorCode.USER_BUSY, "Error subscriberBusyForMtSms after MtForwardSM Request: " + subscriberBusyForMtSms.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
        } else if (mapErrorMessage.isEmAbsentSubscriber()) {
            MAPErrorMessageAbsentSubscriber absentSubscriber = mapErrorMessage.getEmAbsentSubscriber();
            this.onDeliveryError(smsSet, ErrorAction.mobileNotReachableFlag, ErrorCode.ABSENT_SUBSCRIBER, "Error absentSubscriber after MtForwardSM Request: " + absentSubscriber.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
        } else if (mapErrorMessage.isEmAbsentSubscriberSM()) {
            MAPErrorMessageAbsentSubscriberSM absentSubscriber = mapErrorMessage.getEmAbsentSubscriberSM();
            this.onDeliveryError(smsSet, ErrorAction.mobileNotReachableFlag, ErrorCode.ABSENT_SUBSCRIBER, "Error absentSubscriberSM after MtForwardSM Request: " + absentSubscriber.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
        } else if (mapErrorMessage.isEmSMDeliveryFailure()) {
            MAPErrorMessageSMDeliveryFailure smDeliveryFailure = mapErrorMessage.getEmSMDeliveryFailure();
            SmsDeliverReportTpdu tpdu = null;
            try {
                tpdu = smDeliveryFailure.getSmsDeliverReportTpdu();
            } catch (MAPException e) {
            // we skip any possible Exception here
            }
            ErrorAction errAction;
            // checking firstly a case of FailureCause existence in tpdu
            if (tpdu != null && tpdu.getFailureCause() != null) {
                int tpduCauseCode = tpdu.getFailureCause().getCode();
                PermanentTemporaryFailure tpFailureCauseStatus = SmscPropertiesManagement.getInstance().getSmDeliveryFailureTpCause(tpduCauseCode);
                if (tpFailureCauseStatus == PermanentTemporaryFailure.temporary) {
                    errAction = ErrorAction.temporaryFailure;
                } else {
                    errAction = ErrorAction.permanentFailure;
                }
                this.onDeliveryError(smsSet, errAction, ErrorCode.SENDING_SM_FAILED, "Error smDeliveryFailure after MtForwardSM Request: " + smDeliveryFailure.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
            } else {
                // no FailureCause existence in tpdu - then checking DeliveryFailureCause code
                PermanentTemporaryFailure smDlrStatus = SmscPropertiesManagement.getInstance().getSmDeliveryFailure(smDeliveryFailure.getSMEnumeratedDeliveryFailureCause().getCode());
                if (smDeliveryFailure.getSMEnumeratedDeliveryFailureCause() == SMEnumeratedDeliveryFailureCause.memoryCapacityExceeded) {
                    if (smDlrStatus == PermanentTemporaryFailure.permanent)
                        errAction = ErrorAction.permanentFailure;
                    else
                        errAction = ErrorAction.memoryCapacityExceededFlag;
                    this.onDeliveryError(smsSet, errAction, ErrorCode.MESSAGE_QUEUE_FULL, "Error smDeliveryFailure after MtForwardSM Request: " + smDeliveryFailure.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
                } else {
                    if (smDlrStatus == PermanentTemporaryFailure.temporary)
                        errAction = ErrorAction.temporaryFailure;
                    else
                        errAction = ErrorAction.permanentFailure;
                    this.onDeliveryError(smsSet, errAction, ErrorCode.SENDING_SM_FAILED, "Error smDeliveryFailure after MtForwardSM Request: " + smDeliveryFailure.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
                }
            }
        } else if (mapErrorMessage.isEmSystemFailure()) {
            // TODO: may be it is not a permanent case ???
            MAPErrorMessageSystemFailure systemFailure = mapErrorMessage.getEmSystemFailure();
            this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SYSTEM_FAILURE, "Error systemFailure after MtForwardSM Request: " + systemFailure.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
        } else if (mapErrorMessage.isEmFacilityNotSup()) {
            MAPErrorMessageFacilityNotSup facilityNotSup = mapErrorMessage.getEmFacilityNotSup();
            this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.FACILITY_NOT_SUPPORTED, "Error facilityNotSup after MtForwardSM Request: " + facilityNotSup.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
        } else if (mapErrorMessage.isEmExtensionContainer()) {
            MAPErrorMessageExtensionContainer extensionContainer = mapErrorMessage.getEmExtensionContainer();
            switch((int) (long) extensionContainer.getErrorCode()) {
                case MAPErrorCode.dataMissing:
                    this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.DATA_MISSING, "Error dataMissing after MtForwardSM Request: " + extensionContainer.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
                    break;
                case MAPErrorCode.unexpectedDataValue:
                    this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.UNEXPECTED_DATA, "Error unexpectedDataValue after MtForwardSM Request: " + extensionContainer.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
                    break;
                // break;
                case MAPErrorCode.unidentifiedSubscriber:
                    this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.UNDEFINED_SUBSCRIBER, "Error unidentifiedSubscriber after MtForwardSM Request: " + extensionContainer.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
                    break;
                case MAPErrorCode.illegalSubscriber:
                    this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.ILLEGAL_SUBSCRIBER, "Error illegalSubscriber after MtForwardSM Request: " + extensionContainer.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
                    break;
                case MAPErrorCode.illegalEquipment:
                    this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.ILLEGAL_EQUIPMENT, "Error illegalEquipment after MtForwardSM Request: " + extensionContainer.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
                    break;
                default:
                    this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.SYSTEM_FAILURE, "Error after MtForwardSM Request: " + extensionContainer.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
                    break;
            }
        } else {
            this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.SYSTEM_FAILURE, "Error after MtForwardSM Request: " + mapErrorMessage, true, mapErrorMessage, false, ProcessingType.SS7_MT);
        }
    } catch (Throwable e1) {
        logger.severe("Exception in MtSbb.onErrorComponent() when fetching records and issuing events: " + e1.getMessage(), e1);
        markDeliveringIsEnded(true);
    }
}
Also used : MAPErrorMessageSubscriberBusyForMtSms(org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageSubscriberBusyForMtSms) MAPErrorMessageAbsentSubscriberSM(org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageAbsentSubscriberSM) MAPErrorMessageExtensionContainer(org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageExtensionContainer) MAPErrorMessageAbsentSubscriber(org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageAbsentSubscriber) MAPException(org.mobicents.protocols.ss7.map.api.MAPException) MAPErrorMessageSMDeliveryFailure(org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageSMDeliveryFailure) MAPErrorMessageFacilityNotSup(org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageFacilityNotSup) ErrorAction(org.mobicents.smsc.library.ErrorAction) MAPErrorMessageSystemFailure(org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageSystemFailure) SmsSet(org.mobicents.smsc.library.SmsSet) PermanentTemporaryFailure(org.mobicents.smsc.library.PermanentTemporaryFailure) MAPErrorMessage(org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessage)

Example 2 with ErrorAction

use of org.mobicents.smsc.library.ErrorAction 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;
}
Also used : EsmeManagement(org.restcomm.smpp.EsmeManagement) Esme(org.restcomm.smpp.Esme) ArrayList(java.util.ArrayList) FastList(javolution.util.FastList) TargetAddress(org.mobicents.smsc.library.TargetAddress) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) ErrorAction(org.mobicents.smsc.library.ErrorAction) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) Sms(org.mobicents.smsc.library.Sms) ErrorCode(org.mobicents.smsc.library.ErrorCode)

Example 3 with ErrorAction

use of org.mobicents.smsc.library.ErrorAction 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());
    }
}
Also used : EsmeManagement(org.restcomm.smpp.EsmeManagement) ChunkData(org.mobicents.smsc.slee.services.deliverysbb.ChunkData) Esme(org.restcomm.smpp.Esme) SmscProcessingException(org.mobicents.smsc.library.SmscProcessingException) TargetAddress(org.mobicents.smsc.library.TargetAddress) ChunkDataList(org.mobicents.smsc.slee.services.deliverysbb.ChunkDataList) ConfirmMessageInSendingPool(org.mobicents.smsc.slee.services.deliverysbb.ConfirmMessageInSendingPool) SentItemsList(org.mobicents.smsc.slee.services.deliverysbb.SentItemsList) ErrorAction(org.mobicents.smsc.library.ErrorAction) Sms(org.mobicents.smsc.library.Sms) SentItem(org.mobicents.smsc.slee.services.deliverysbb.SentItem) SmsSet(org.mobicents.smsc.library.SmsSet)

Example 4 with ErrorAction

use of org.mobicents.smsc.library.ErrorAction 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);
}
Also used : EsmeManagement(org.restcomm.smpp.EsmeManagement) Esme(org.restcomm.smpp.Esme) FastList(javolution.util.FastList) ArrayList(java.util.ArrayList) TargetAddress(org.mobicents.smsc.library.TargetAddress) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) ErrorAction(org.mobicents.smsc.library.ErrorAction) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) Sms(org.mobicents.smsc.library.Sms) ErrorCode(org.mobicents.smsc.library.ErrorCode)

Aggregations

ErrorAction (org.mobicents.smsc.library.ErrorAction)4 Sms (org.mobicents.smsc.library.Sms)3 TargetAddress (org.mobicents.smsc.library.TargetAddress)3 Esme (org.restcomm.smpp.Esme)3 EsmeManagement (org.restcomm.smpp.EsmeManagement)3 ArrayList (java.util.ArrayList)2 FastList (javolution.util.FastList)2 ISDNAddressString (org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString)2 ErrorCode (org.mobicents.smsc.library.ErrorCode)2 SmsSet (org.mobicents.smsc.library.SmsSet)2 MProcResult (org.mobicents.smsc.mproc.impl.MProcResult)2 MAPException (org.mobicents.protocols.ss7.map.api.MAPException)1 MAPErrorMessage (org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessage)1 MAPErrorMessageAbsentSubscriber (org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageAbsentSubscriber)1 MAPErrorMessageAbsentSubscriberSM (org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageAbsentSubscriberSM)1 MAPErrorMessageExtensionContainer (org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageExtensionContainer)1 MAPErrorMessageFacilityNotSup (org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageFacilityNotSup)1 MAPErrorMessageSMDeliveryFailure (org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageSMDeliveryFailure)1 MAPErrorMessageSubscriberBusyForMtSms (org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageSubscriberBusyForMtSms)1 MAPErrorMessageSystemFailure (org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageSystemFailure)1