Search in sources :

Example 71 with Sms

use of org.mobicents.smsc.library.Sms 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 72 with Sms

use of org.mobicents.smsc.library.Sms 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 73 with Sms

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

the class DeliveryCommonSbb method postProcessRerouted.

/**
 * Processing messages that were rescheduled (sms.inSystem=sent in live database).
 *
 * @param lstRerouted
 * @param lstNewNetworkId
 */
protected void postProcessRerouted(ArrayList<Sms> lstRerouted, ArrayList<Integer> lstNewNetworkId) {
    // next we are initiating another delivering process
    try {
        for (int i1 = 0; i1 < lstRerouted.size(); i1++) {
            Sms sms = lstRerouted.get(i1);
            int newNetworkId = lstNewNetworkId.get(i1);
            sms.setReroutingCount(sms.getReroutingCount() + 1);
            sms.setTargetIdOnDeliveryStart(smsSet.getTargetId());
            MessageUtil.createNewSmsSetForSms(sms);
            sms.getSmsSet().setNetworkId(newNetworkId);
            this.scheduler.injectSmsOnFly(sms.getSmsSet(), true);
        }
    } catch (Exception e) {
        this.logger.severe("Exception when DeliveryCommonSbb.postProcessRerouted() - rerouting" + e.getMessage(), e);
    }
}
Also used : Sms(org.mobicents.smsc.library.Sms) CreateException(javax.slee.CreateException) PersistenceException(org.mobicents.smsc.cassandra.PersistenceException)

Example 74 with Sms

use of org.mobicents.smsc.library.Sms 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 75 with Sms

use of org.mobicents.smsc.library.Sms 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)

Aggregations

Sms (org.mobicents.smsc.library.Sms)139 SmsSet (org.mobicents.smsc.library.SmsSet)62 Test (org.testng.annotations.Test)43 Date (java.util.Date)42 ArrayList (java.util.ArrayList)35 ISDNAddressString (org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString)33 TargetAddress (org.mobicents.smsc.library.TargetAddress)30 MAPDialogSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy)27 MAPServiceSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy)27 ISDNAddressStringImpl (org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl)26 AddressString (org.restcomm.protocols.ss7.map.api.primitives.AddressString)24 SmscPropertiesManagement (org.mobicents.smsc.domain.SmscPropertiesManagement)23 UUID (java.util.UUID)22 PreparedStatementCollection (org.mobicents.smsc.cassandra.PreparedStatementCollection)21 SmsSetEvent (org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent)21 SmsProxy (org.mobicents.smsc.slee.resources.persistence.SmsProxy)20 SM_RP_DA (org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA)19 SmsSignalInfo (org.restcomm.protocols.ss7.map.api.service.sms.SmsSignalInfo)19 MAPApplicationContextVersion (org.restcomm.protocols.ss7.map.api.MAPApplicationContextVersion)17 UserData (org.restcomm.protocols.ss7.map.api.smstpdu.UserData)17