Search in sources :

Example 6 with MProcResult

use of org.mobicents.smsc.mproc.impl.MProcResult in project smscgateway by RestComm.

the class DeliveryCommonSbb method applyMprocRulesOnSuccess.

// *********
// applying of mproc rules
/**
 * mproc rules applying for delivery phase for success case
 *
 * @param sms
 * @param processingType
 */
protected void applyMprocRulesOnSuccess(Sms sms, ProcessingType processingType) {
    // PostDeliveryProcessor - success case
    MProcResult mProcResult = MProcManagement.getInstance().applyMProcDelivery(itsMProcRa, sms, false, processingType);
    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 DeliverySuccess: targetId=");
                sb.append(smst.getSmsSet().getTargetId());
                sb.append(", sms=");
                sb.append(smst);
                this.logger.info(sb.toString());
            }
        }
    }
}
Also used : MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) Sms(org.mobicents.smsc.library.Sms) FastList(javolution.util.FastList) TargetAddress(org.mobicents.smsc.library.TargetAddress)

Example 7 with MProcResult

use of org.mobicents.smsc.mproc.impl.MProcResult in project smscgateway by RestComm.

the class DeliveryCommonSbb method applyMprocRulesOnImsiResponse.

/**
 * mproc rules applying for delivery phase after SRI successful response
 *
 * @param smsSet
 * @param lstPermFailured
 * @param processingType
 */
protected void applyMprocRulesOnImsiResponse(SmsSet smsSet, ArrayList<Sms> lstPermFailured, ArrayList<Sms> lstRerouted, ArrayList<Integer> lstNewNetworkId, ISDNAddressString networkNode, String imsiData) {
    Sms sms = this.getMessageInSendingPool(0);
    if (sms != null) {
        while (true) {
            MProcResult mProcResult = MProcManagement.getInstance().applyMProcImsiRequest(itsMProcRa, sms, imsiData, networkNode.getAddress(), networkNode.getNumberingPlan().getIndicator(), networkNode.getAddressNature().getIndicator());
            if (mProcResult.isMessageDropped()) {
                lstPermFailured.add(sms);
                if (this.logger.isInfoEnabled()) {
                    StringBuilder sb = new StringBuilder();
                    sb.append("Dropping message after SRI response: targetId=");
                    sb.append(sms.getSmsSet().getTargetId());
                    sb.append(", sms=");
                    sb.append(sms);
                    this.logger.info(sb.toString());
                }
                this.commitSendingPoolMsgCount();
                sms = this.obtainNextMessage(ProcessingType.SS7_SRI);
                if (sms == null)
                    break;
                else
                    continue;
            }
            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 after SRI response, 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());
                } else if (mProcResult.getNewNetworkId() == sms.getSmsSet().getNetworkId()) {
                // we do not reroute for the same networkId
                } else {
                    lstRerouted.add(sms);
                    lstNewNetworkId.add(mProcResult.getNewNetworkId());
                    if (this.logger.isInfoEnabled()) {
                        StringBuilder sb = new StringBuilder();
                        sb.append("Rerouting message after SRI response: targetId=");
                        sb.append(sms.getSmsSet().getTargetId());
                        sb.append(", newNetworkId=");
                        sb.append(mProcResult.getNewNetworkId());
                        sb.append(", sms=");
                        sb.append(sms);
                        this.logger.info(sb.toString());
                    }
                    this.commitSendingPoolMsgCount();
                    sms = this.obtainNextMessage(ProcessingType.SS7_SRI);
                    if (sms == null)
                        break;
                    else
                        continue;
                }
            }
            break;
        }
    }
}
Also used : MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) Sms(org.mobicents.smsc.library.Sms)

Example 8 with MProcResult

use of org.mobicents.smsc.mproc.impl.MProcResult in project smscgateway by RestComm.

the class MProcManagement method applyMProcDeliveryTempFailure.

public MProcResult applyMProcDeliveryTempFailure(final MProcRuleRaProvider anMProcRuleRa, Sms sms, ProcessingType processingType) {
    if (this.mprocs.size() == 0) {
        return new MProcResult();
    }
    FastList<MProcRule> cur = this.mprocs;
    PostDeliveryTempFailureProcessorImpl pap = new PostDeliveryTempFailureProcessorImpl(this.smscPropertiesManagement.getDefaultValidityPeriodHours(), this.smscPropertiesManagement.getMaxValidityPeriodHours(), logger);
    MProcMessage message = new MProcMessageImpl(sms, processingType, null);
    try {
        for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
            MProcRule rule = n.getValue();
            if (rule.isForPostDeliveryTempFailureState() && rule.matchesPostDeliveryTempFailure(message)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("MRule matches at DeliveryTempFailure phase to a message: rule: " + rule + "message: " + sms);
                }
                rule.onPostDeliveryTempFailure(anMProcRuleRa, pap, message);
            }
        }
    } catch (Throwable e) {
        logger.error("Exception when invoking rule.matches(message) or onPostDeliveryTempFailure(): " + e.getMessage(), e);
        return new MProcResult();
    }
    FastList<MProcNewMessage> newMsgs = pap.getPostedMessages();
    MProcResult res = new MProcResult();
    FastList<Sms> res0 = new FastList<Sms>();
    for (FastList.Node<MProcNewMessage> n = newMsgs.head(), end = newMsgs.tail(); (n = n.getNext()) != end; ) {
        MProcNewMessageImpl newMsg = (MProcNewMessageImpl) n.getValue();
        res0.add(newMsg.getSmsContent());
    }
    res.setMessageList(res0);
    if (pap.isNeedDropMessages()) {
        res.setMessageDropped(true);
    }
    if (pap.isNeedRerouteMessages()) {
        res.setMessageIsRerouted(true);
        res.setNewNetworkId(pap.getNewNetworkId());
    }
    return res;
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) MProcNewMessage(org.mobicents.smsc.mproc.MProcNewMessage) FastList(javolution.util.FastList) PostDeliveryTempFailureProcessorImpl(org.mobicents.smsc.mproc.impl.PostDeliveryTempFailureProcessorImpl) MProcNewMessageImpl(org.mobicents.smsc.mproc.impl.MProcNewMessageImpl) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) MProcMessageImpl(org.mobicents.smsc.mproc.impl.MProcMessageImpl) Sms(org.mobicents.smsc.library.Sms) MProcMessage(org.mobicents.smsc.mproc.MProcMessage)

Example 9 with MProcResult

use of org.mobicents.smsc.mproc.impl.MProcResult in project smscgateway by RestComm.

the class MProcManagement method applyMProcPreDelivery.

public MProcResult applyMProcPreDelivery(final MProcRuleRaProvider anMProcRuleRa, Sms sms, ProcessingType processingType) {
    if (this.mprocs.size() == 0) {
        return new MProcResult();
    }
    FastList<MProcRule> cur = this.mprocs;
    PostPreDeliveryProcessorImpl pap = new PostPreDeliveryProcessorImpl(this.smscPropertiesManagement.getDefaultValidityPeriodHours(), this.smscPropertiesManagement.getMaxValidityPeriodHours(), logger);
    MProcMessage message = new MProcMessageImpl(sms, processingType, null);
    try {
        for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
            MProcRule rule = n.getValue();
            if (rule.isForPostPreDeliveryState() && rule.matchesPostPreDelivery(message)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("MRule matches at PreDelivery phase to a message: rule: " + rule + "message: " + sms);
                }
                rule.onPostPreDelivery(anMProcRuleRa, pap, message);
            }
        }
    } catch (Throwable e) {
        logger.error("Exception when invoking rule.matches(message) or onPostPreDelivery(): " + e.getMessage(), e);
        return new MProcResult();
    }
    FastList<MProcNewMessage> newMsgs = pap.getPostedMessages();
    MProcResult res = new MProcResult();
    FastList<Sms> res0 = new FastList<Sms>();
    for (FastList.Node<MProcNewMessage> n = newMsgs.head(), end = newMsgs.tail(); (n = n.getNext()) != end; ) {
        MProcNewMessageImpl newMsg = (MProcNewMessageImpl) n.getValue();
        res0.add(newMsg.getSmsContent());
    }
    res.setMessageList(res0);
    if (pap.isNeedDropMessages()) {
        res.setMessageDropped(true);
    }
    if (pap.isNeedRerouteMessages()) {
        res.setMessageIsRerouted(true);
        res.setNewNetworkId(pap.getNewNetworkId());
    }
    return res;
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) MProcNewMessage(org.mobicents.smsc.mproc.MProcNewMessage) FastList(javolution.util.FastList) MProcNewMessageImpl(org.mobicents.smsc.mproc.impl.MProcNewMessageImpl) PostPreDeliveryProcessorImpl(org.mobicents.smsc.mproc.impl.PostPreDeliveryProcessorImpl) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) MProcMessageImpl(org.mobicents.smsc.mproc.impl.MProcMessageImpl) Sms(org.mobicents.smsc.library.Sms) MProcMessage(org.mobicents.smsc.mproc.MProcMessage)

Example 10 with MProcResult

use of org.mobicents.smsc.mproc.impl.MProcResult in project smscgateway by RestComm.

the class MProcManagement method applyMProcArrival.

public MProcResult applyMProcArrival(final MProcRuleRaProvider anMProcRuleRa, Sms sms, PersistenseCommonInterface persistence) {
    if (this.mprocs.size() == 0) {
        FastList<Sms> res0 = new FastList<Sms>();
        res0.add(sms);
        MProcResult res = new MProcResult();
        res.setMessageList(res0);
        return res;
    }
    FastList<MProcRule> cur = this.mprocs;
    PostArrivalProcessorImpl pap = new PostArrivalProcessorImpl(this.smscPropertiesManagement.getDefaultValidityPeriodHours(), this.smscPropertiesManagement.getMaxValidityPeriodHours(), logger);
    MProcMessage message = new MProcMessageImpl(sms, null, persistence);
    try {
        for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
            MProcRule rule = n.getValue();
            if (rule.isForPostArrivalState() && rule.matchesPostArrival(message)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("MRule matches at Arrival phase to a message: rule: " + rule + "message: " + sms);
                }
                pap.setRuleIdInProcessing(rule.getId());
                rule.onPostArrival(anMProcRuleRa, pap, message);
            }
        }
    } catch (Throwable e) {
        logger.error("Exception when invoking rule.matches(message) or applyMProcArrival: " + e.getMessage(), e);
        MProcResult res = new MProcResult();
        res.setMessageDropped(true);
        return res;
    }
    MProcResult res = new MProcResult();
    FastList<Sms> res0 = new FastList<Sms>();
    res.setMessageList(res0);
    FastList<MProcNewMessage> newMsgs = pap.getPostedMessages();
    if (pap.isNeedDropMessage()) {
        res.setMessageDropped(true);
        res.setRuleIdDropReject(pap.getRuleIdDropReject());
    } else if (pap.isNeedRejectMessage()) {
        res.setMessageRejected(true);
        // res.setMprocRejectingRuleId(pap.);
        res.setMapErrorCode(pap.getMapErrorCode());
        res.setHttpErrorCode(pap.getHttpErrorCode());
        res.setSmppErrorCode(pap.getSmppErrorCode());
        res.setRuleIdDropReject(pap.getRuleIdDropReject());
    } else {
        res0.add(sms);
    }
    for (FastList.Node<MProcNewMessage> n = newMsgs.head(), end = newMsgs.tail(); (n = n.getNext()) != end; ) {
        MProcNewMessageImpl newMsg = (MProcNewMessageImpl) n.getValue();
        res0.add(newMsg.getSmsContent());
    }
    return res;
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) MProcNewMessage(org.mobicents.smsc.mproc.MProcNewMessage) FastList(javolution.util.FastList) MProcNewMessageImpl(org.mobicents.smsc.mproc.impl.MProcNewMessageImpl) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) MProcMessageImpl(org.mobicents.smsc.mproc.impl.MProcMessageImpl) PostArrivalProcessorImpl(org.mobicents.smsc.mproc.impl.PostArrivalProcessorImpl) Sms(org.mobicents.smsc.library.Sms) MProcMessage(org.mobicents.smsc.mproc.MProcMessage)

Aggregations

MProcResult (org.mobicents.smsc.mproc.impl.MProcResult)14 FastList (javolution.util.FastList)12 Sms (org.mobicents.smsc.library.Sms)11 TargetAddress (org.mobicents.smsc.library.TargetAddress)6 MProcMessage (org.mobicents.smsc.mproc.MProcMessage)6 MProcRule (org.mobicents.smsc.mproc.MProcRule)6 MProcMessageImpl (org.mobicents.smsc.mproc.impl.MProcMessageImpl)5 MProcNewMessage (org.mobicents.smsc.mproc.MProcNewMessage)4 MProcNewMessageImpl (org.mobicents.smsc.mproc.impl.MProcNewMessageImpl)4 Esme (org.restcomm.smpp.Esme)4 EsmeManagement (org.restcomm.smpp.EsmeManagement)4 ArrayList (java.util.ArrayList)2 CreateException (javax.slee.CreateException)2 PersistenceException (org.mobicents.smsc.cassandra.PersistenceException)2 ErrorAction (org.mobicents.smsc.library.ErrorAction)2 ErrorCode (org.mobicents.smsc.library.ErrorCode)2 EventType (org.mobicents.smsc.library.EventType)2 SmscProcessingException (org.mobicents.smsc.library.SmscProcessingException)2 ISDNAddressString (org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString)2 CorrelationIdValue (org.mobicents.smsc.library.CorrelationIdValue)1