Search in sources :

Example 1 with SmppTransaction

use of org.restcomm.slee.resource.smpp.SmppTransaction in project smscgateway by RestComm.

the class TxSmppServerSbb method onSubmitSmLocal.

private void onSubmitSmLocal(final TxSmppServerSbbUsage anSbbUsage, final com.cloudhopper.smpp.pdu.SubmitSm event, final ActivityContextInterface aci) {
    // TODO remove it ...........................
    // long l2 = Date.parse(event.getServiceType());
    // Date dt0 = new Date(l2);
    Date dt0 = new Date();
    Date dt1 = new Date();
    // TODO remove it ...........................
    SmppTransaction smppServerTransaction = (SmppTransaction) aci.getActivity();
    Esme esme = smppServerTransaction.getEsme();
    String esmeName = esme.getName();
    long timestampB = 0;
    if (this.logger.isFineEnabled()) {
        this.logger.fine("\nReceived SUBMIT_SM = " + event + " from Esme name=" + esmeName);
    }
    CheckMessageLimitResult cres = esme.onMessageReceived(1);
    if (cres.getResult() != CheckMessageLimitResult.Result.ok) {
        if (cres.getResult() == CheckMessageLimitResult.Result.firstFault) {
            this.updateOverrateCounters(cres);
            this.logger.info(cres.getMessage());
        }
        if (smscPropertiesManagement.isGenerateRejectionCdr()) {
            generateCDR(parseShortMessageText(event), esme.getNetworkId(), esme.getSystemId(), event.getSourceAddress().getAddress(), event.getSourceAddress().getTon(), event.getSourceAddress().getNpi(), event.getDestAddress().getAddress(), event.getDestAddress().getTon(), event.getDestAddress().getNpi(), CdrGenerator.CDR_SUBMIT_FAILED_ESME, cres.getMessage(), true);
        }
        SubmitSmResp response = event.createResponse();
        response.setCommandStatus(SmppConstants.STATUS_THROTTLED);
        String s = cres.getMessage();
        if (s.length() > 255)
            s = s.substring(0, 255);
        Tlv tlv;
        try {
            tlv = TlvUtil.createNullTerminatedStringTlv(SmppConstants.TAG_ADD_STATUS_INFO, s);
            response.addOptionalParameter(tlv);
        } catch (TlvConvertException e) {
            anSbbUsage.incrementCounterErrorSubmitSm(ONE);
            this.logger.severe("TlvConvertException while storing TAG_ADD_STATUS_INFO Tlv parameter", e);
        }
        // Lets send the Response with error here
        try {
            this.smppServerSessions.sendResponsePdu(esme, event, response);
            timestampB = System.currentTimeMillis();
        } catch (Exception e) {
            anSbbUsage.incrementCounterErrorSubmitSmResponding(ONE);
            this.logger.severe("Error while trying to send SubmitSmResponse. Message: " + e.getMessage() + ".\nResponse: " + response + ".", e);
        }
        try {
            TargetAddress ta = createDestTargetAddress(event.getDestAddress(), esme.getNetworkId());
            Sms sms = this.createSmsEvent(event, esme, ta, persistence);
            sms.setTimestampB(timestampB);
            generateFailureDetailedCdr(sms, EventType.IN_SMPP_REJECT_CONG, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM, SmppConstants.STATUS_THROTTLED, esme.getRemoteAddressAndPort(), event.getSequenceNumber());
        } catch (SmscProcessingException e1) {
        }
        return;
    }
    Sms sms = null;
    try {
        TargetAddress ta = createDestTargetAddress(event.getDestAddress(), esme.getNetworkId());
        sms = this.createSmsEvent(event, esme, ta, persistence);
        this.processSms(sms, persistence, esme, event, null, null, IncomingMessageType.submit_sm, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM, event.getSequenceNumber());
    } catch (SmscProcessingException e1) {
        anSbbUsage.incrementCounterErrorSubmitSm(ONE);
        SbbStatsUtils.handleProcessingException(e1, anSbbUsage);
        if (!e1.isSkipErrorLogging()) {
            if (e1.isIsWarning()) {
                this.logger.warning(e1.getMessage());
            } else {
                this.logger.severe(e1.getMessage(), e1);
            }
            smscStatAggregator.updateMsgInFailedAll();
        }
        if (smscPropertiesManagement.isGenerateRejectionCdr() && !e1.isMessageRejectCdrCreated()) {
            if (sms != null) {
                generateCDR(sms, CdrGenerator.CDR_SUBMIT_FAILED_ESME, e1.getMessage(), false, true);
            } else {
                generateCDR(parseShortMessageText(event), esme.getNetworkId(), esme.getSystemId(), event.getSourceAddress().getAddress(), event.getSourceAddress().getTon(), event.getSourceAddress().getNpi(), event.getDestAddress().getAddress(), event.getDestAddress().getTon(), event.getDestAddress().getNpi(), CdrGenerator.CDR_SUBMIT_FAILED_ESME, e1.getMessage(), true);
            }
        }
        SubmitSmResp response = event.createResponse();
        response.setCommandStatus(e1.getSmppErrorCode());
        String s = e1.getMessage();
        if (s != null) {
            if (s.length() > 255)
                s = s.substring(0, 255);
            Tlv tlv;
            try {
                tlv = TlvUtil.createNullTerminatedStringTlv(SmppConstants.TAG_ADD_STATUS_INFO, s);
                response.addOptionalParameter(tlv);
            } catch (TlvConvertException e) {
                this.logger.severe("TlvConvertException while storing TAG_ADD_STATUS_INFO Tlv parameter", e);
            }
        }
        // Lets send the Response with error here
        try {
            this.smppServerSessions.sendResponsePdu(esme, event, response);
            timestampB = System.currentTimeMillis();
        } catch (Exception e) {
            anSbbUsage.incrementCounterErrorSubmitSmResponding(ONE);
            this.logger.severe("Error while trying to send SubmitSmResponse. Message: " + e.getMessage() + ".\nResponse: " + response + ".", e);
        }
        EventType eventType = null;
        if (e1.getInternalErrorCode() == SmscProcessingException.INTERNAL_ERROR_STATE_OVERLOADED) {
            eventType = EventType.IN_SMPP_REJECT_CONG;
        } else {
            eventType = EventType.IN_SMPP_REJECT_FORBIDDEN;
        }
        if (sms != null) {
            sms.setTimestampB(timestampB);
            generateRejectDetailedCdr(e1.getInternalErrorCode(), sms, eventType, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM, e1.getSmppErrorCode(), esme.getRemoteAddressAndPort(), event.getSequenceNumber());
        } else {
            generateRejectDetailedCdr(e1.getInternalErrorCode(), event, esme, eventType, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM, e1.getSmppErrorCode(), parseShortMessageText(event), timestampB);
        }
        return;
    } catch (Throwable e1) {
        anSbbUsage.incrementCounterErrorSubmitSm(ONE);
        String s = "Exception when processing SubmitSm message: " + e1.getMessage();
        this.logger.severe(s, e1);
        smscStatAggregator.updateMsgInFailedAll();
        if (smscPropertiesManagement.isGenerateRejectionCdr()) {
            generateCDR(parseShortMessageText(event), esme.getNetworkId(), esme.getSystemId(), event.getSourceAddress().getAddress(), event.getSourceAddress().getTon(), event.getSourceAddress().getNpi(), event.getDestAddress().getAddress(), event.getDestAddress().getTon(), event.getDestAddress().getNpi(), CdrGenerator.CDR_SUBMIT_FAILED_ESME, e1.getMessage(), true);
        }
        SubmitSmResp response = event.createResponse();
        response.setCommandStatus(SmppConstants.STATUS_SYSERR);
        if (s.length() > 255)
            s = s.substring(0, 255);
        Tlv tlv;
        try {
            tlv = TlvUtil.createNullTerminatedStringTlv(SmppConstants.TAG_ADD_STATUS_INFO, s);
            response.addOptionalParameter(tlv);
        } catch (TlvConvertException e) {
            this.logger.severe("TlvConvertException while storing TAG_ADD_STATUS_INFO Tlv parameter", e);
        }
        // Lets send the Response with error here
        try {
            this.smppServerSessions.sendResponsePdu(esme, event, response);
            if (sms != null) {
                sms.setTimestampB(System.currentTimeMillis());
                generateFailureDetailedCdr(sms, EventType.IN_SMPP_ERROR, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM, SmppConstants.STATUS_SYSERR, esme.getRemoteAddressAndPort(), event.getSequenceNumber());
            }
        } catch (Exception e) {
            anSbbUsage.incrementCounterErrorSubmitSmResponding(ONE);
            this.logger.severe("Error while trying to send SubmitSmResponse. Message: " + e.getMessage() + ".\nResponse: " + response + ".", e);
        }
        return;
    }
    SubmitSmResp response = event.createResponse();
    response.setMessageId(sms.getMessageIdText());
    // Lets send the Response with success here
    try {
        if (sms.getMessageDeliveryResultResponse() == null) {
            this.smppServerSessions.sendResponsePdu(esme, event, response);
            sms.setTimestampB(System.currentTimeMillis());
            generateDetailedCDR(sms, EventType.IN_SMPP_RECEIVED, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM, SmppConstants.STATUS_OK, esme.getRemoteAddressAndPort(), event.getSequenceNumber());
        }
    } catch (Throwable e) {
        anSbbUsage.incrementCounterErrorSubmitSmResponding(ONE);
        this.logger.severe("Error while trying to send SubmitSmResponse. Message: " + e.getMessage() + ".\nResponse: " + response + ".", e);
    }
    // TODO remove it ...........................
    Date dt3 = new Date();
    SmscStatProvider.getInstance().setParam1((int) (dt3.getTime() - dt0.getTime()));
    SmscStatProvider.getInstance().setParam2((int) (dt3.getTime() - dt1.getTime()));
// TODO remove it ...........................
}
Also used : TlvConvertException(com.cloudhopper.smpp.tlv.TlvConvertException) SmppTransaction(org.restcomm.slee.resource.smpp.SmppTransaction) Esme(org.restcomm.smpp.Esme) CheckMessageLimitResult(org.restcomm.smpp.CheckMessageLimitResult) Date(java.util.Date) ParseException(java.text.ParseException) TlvConvertException(com.cloudhopper.smpp.tlv.TlvConvertException) RecoverablePduException(com.cloudhopper.smpp.type.RecoverablePduException) CharacterCodingException(java.nio.charset.CharacterCodingException) SmppInvalidArgumentException(com.cloudhopper.smpp.type.SmppInvalidArgumentException) PersistenceException(org.mobicents.smsc.cassandra.PersistenceException) SubmitSmResp(com.cloudhopper.smpp.pdu.SubmitSmResp) Tlv(com.cloudhopper.smpp.tlv.Tlv)

Example 2 with SmppTransaction

use of org.restcomm.slee.resource.smpp.SmppTransaction in project smscgateway by RestComm.

the class TxSmppServerSbb method onSubmitMultiLocal.

private void onSubmitMultiLocal(final TxSmppServerSbbUsage anSbbUsage, final com.cloudhopper.smpp.pdu.SubmitMulti event, final ActivityContextInterface aci) {
    SmppTransaction smppServerTransaction = (SmppTransaction) aci.getActivity();
    Esme esme = smppServerTransaction.getEsme();
    String esmeName = esme.getName();
    if (this.logger.isFineEnabled()) {
        this.logger.fine("\nReceived SUBMIT_MULTI = " + event + " from Esme name=" + esmeName);
    }
    List<Address> addrList = event.getDestAddresses();
    int msgCnt = 0;
    if (addrList != null)
        msgCnt = addrList.size();
    CheckMessageLimitResult cres = esme.onMessageReceived(msgCnt);
    if (cres.getResult() != CheckMessageLimitResult.Result.ok) {
        if (cres.getResult() == CheckMessageLimitResult.Result.firstFault) {
            this.updateOverrateCounters(cres);
            this.logger.info(cres.getMessage());
        }
        if (smscPropertiesManagement.isGenerateRejectionCdr()) {
            generateCDR(parseShortMessageText(event), esme.getNetworkId(), esme.getSystemId(), event.getSourceAddress().getAddress(), event.getSourceAddress().getTon(), event.getSourceAddress().getNpi(), event.getDestAddress().getAddress(), event.getDestAddress().getTon(), event.getDestAddress().getNpi(), CdrGenerator.CDR_SUBMIT_FAILED_ESME, cres.getMessage(), true);
        }
        SubmitMultiResp response = event.createResponse();
        response.setCommandStatus(SmppConstants.STATUS_THROTTLED);
        String s = cres.getMessage();
        if (s.length() > 255)
            s = s.substring(0, 255);
        Tlv tlv;
        try {
            tlv = TlvUtil.createNullTerminatedStringTlv(SmppConstants.TAG_ADD_STATUS_INFO, s);
            response.addOptionalParameter(tlv);
        } catch (TlvConvertException e) {
            anSbbUsage.incrementCounterErrorSubmitMultiSm(ONE);
            this.logger.severe("TlvConvertException while storing TAG_ADD_STATUS_INFO Tlv parameter", e);
        }
        // Lets send the Response with error here
        long timestampB = 0L;
        try {
            this.smppServerSessions.sendResponsePdu(esme, event, response);
            timestampB = System.currentTimeMillis();
        } catch (Exception e) {
            anSbbUsage.incrementCounterErrorSubmitMultiSmResponding(ONE);
            this.logger.severe("Error while trying to send SubmitMultiResponse=" + response, e);
        }
        try {
            TargetAddress ta = createDestTargetAddress(event.getDestAddress(), esme.getNetworkId());
            Sms sms = this.createSmsEvent(event, esme, ta, persistence);
            sms.setTimestampB(timestampB);
            generateFailureDetailedCdr(sms, EventType.IN_SMPP_REJECT_CONG, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITMULTI, SmppConstants.STATUS_THROTTLED, esme.getRemoteAddressAndPort(), event.getSequenceNumber());
        } catch (SmscProcessingException e1) {
        }
        return;
    }
    SubmitMultiParseResult parseResult;
    Sms singleSms = null;
    try {
        parseResult = this.createSmsEventMulti(event, esme, persistence, esme.getNetworkId());
        for (Sms sms : parseResult.getParsedMessages()) {
            singleSms = sms;
            this.processSms(sms, persistence, esme, null, null, event, IncomingMessageType.submit_multi, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITMULTI, event.getSequenceNumber());
        }
    } catch (SmscProcessingException e1) {
        anSbbUsage.incrementCounterErrorSubmitMultiSm(ONE);
        SbbStatsUtils.handleProcessingException(e1, anSbbUsage);
        if (!e1.isSkipErrorLogging()) {
            if (e1.isIsWarning()) {
                this.logger.warning(e1.getMessage());
            } else {
                this.logger.severe(e1.getMessage(), e1);
            }
            smscStatAggregator.updateMsgInFailedAll();
        }
        if (smscPropertiesManagement.isGenerateRejectionCdr() && !e1.isMessageRejectCdrCreated()) {
            if (singleSms != null) {
                generateCDR(singleSms, CdrGenerator.CDR_SUBMIT_FAILED_ESME, e1.getMessage(), false, true);
            } else {
                generateCDR(parseShortMessageText(event), esme.getNetworkId(), esme.getSystemId(), event.getSourceAddress().getAddress(), event.getSourceAddress().getTon(), event.getSourceAddress().getNpi(), event.getDestAddress().getAddress(), event.getDestAddress().getTon(), event.getDestAddress().getNpi(), CdrGenerator.CDR_SUBMIT_FAILED_ESME, e1.getMessage(), true);
            }
        }
        SubmitMultiResp response = event.createResponse();
        response.setCommandStatus(e1.getSmppErrorCode());
        String s = e1.getMessage();
        if (s != null) {
            if (s.length() > 255)
                s = s.substring(0, 255);
            Tlv tlv;
            try {
                tlv = TlvUtil.createNullTerminatedStringTlv(SmppConstants.TAG_ADD_STATUS_INFO, s);
                response.addOptionalParameter(tlv);
            } catch (TlvConvertException e) {
                this.logger.severe("TlvConvertException while storing TAG_ADD_STATUS_INFO Tlv parameter", e);
            }
        }
        // Lets send the Response with error here
        long timestampB = 0L;
        try {
            this.smppServerSessions.sendResponsePdu(esme, event, response);
            timestampB = System.currentTimeMillis();
        } catch (Exception e) {
            anSbbUsage.incrementCounterErrorSubmitMultiSmResponding(ONE);
            this.logger.severe("Error while trying to send SubmitMultiResponse=" + response, e);
        }
        EventType eventType = null;
        if (e1.getInternalErrorCode() == SmscProcessingException.INTERNAL_ERROR_STATE_OVERLOADED) {
            eventType = EventType.IN_SMPP_REJECT_CONG;
        } else {
            eventType = EventType.IN_SMPP_REJECT_FORBIDDEN;
        }
        if (singleSms != null) {
            singleSms.setTimestampB(timestampB);
            generateRejectDetailedCdr(e1.getInternalErrorCode(), singleSms, eventType, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITMULTI, e1.getSmppErrorCode(), esme.getRemoteAddressAndPort(), event.getSequenceNumber());
        } else {
            generateRejectDetailedCdr(e1.getInternalErrorCode(), event, esme, eventType, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITMULTI, e1.getSmppErrorCode(), parseShortMessageText(event), timestampB);
        }
        return;
    } catch (Throwable e1) {
        anSbbUsage.incrementCounterErrorSubmitMultiSm(ONE);
        String s = "Exception when processing SubmitMulti message: " + e1.getMessage();
        this.logger.severe(s, e1);
        smscStatAggregator.updateMsgInFailedAll();
        if (smscPropertiesManagement.isGenerateRejectionCdr()) {
            generateCDR(parseShortMessageText(event), esme.getNetworkId(), esme.getSystemId(), event.getSourceAddress().getAddress(), event.getSourceAddress().getTon(), event.getSourceAddress().getNpi(), event.getDestAddress().getAddress(), event.getDestAddress().getTon(), event.getDestAddress().getNpi(), CdrGenerator.CDR_SUBMIT_FAILED_ESME, e1.getMessage(), true);
        }
        SubmitMultiResp response = event.createResponse();
        response.setCommandStatus(SmppConstants.STATUS_SYSERR);
        if (s.length() > 255)
            s = s.substring(0, 255);
        Tlv tlv;
        try {
            tlv = TlvUtil.createNullTerminatedStringTlv(SmppConstants.TAG_ADD_STATUS_INFO, s);
            response.addOptionalParameter(tlv);
        } catch (TlvConvertException e) {
            this.logger.severe("TlvConvertException while storing TAG_ADD_STATUS_INFO Tlv parameter", e);
        }
        // Lets send the Response with error here
        try {
            this.smppServerSessions.sendResponsePdu(esme, event, response);
            if (singleSms != null) {
                singleSms.setTimestampB(System.currentTimeMillis());
                generateFailureDetailedCdr(singleSms, EventType.IN_SMPP_ERROR, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITMULTI, SmppConstants.STATUS_SYSERR, esme.getRemoteAddressAndPort(), event.getSequenceNumber());
            }
            anSbbUsage.incrementCounterErrorSubmitMultiSmResponding(ONE);
        } catch (Exception e) {
            this.logger.severe("Error while trying to send SubmitMultiResponse=" + response, e);
        }
        return;
    }
    SubmitMultiResp response = event.createResponse();
    Sms sms = null;
    if (parseResult.getParsedMessages().size() > 0)
        sms = parseResult.getParsedMessages().get(0);
    if (sms != null)
        response.setMessageId(sms.getMessageIdText());
    for (UnsucessfulSME usme : parseResult.getBadAddresses()) {
        try {
            response.addUnsucessfulSME(usme);
        } catch (SmppInvalidArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    // Lets send the Response with success here
    try {
        if (sms == null || sms.getMessageDeliveryResultResponse() == null) {
            this.smppServerSessions.sendResponsePdu(esme, event, response);
            sms.setTimestampB(System.currentTimeMillis());
            generateDetailedCDR(sms, EventType.IN_SMPP_RECEIVED, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITMULTI, SmppConstants.STATUS_OK, esme.getRemoteAddressAndPort(), event.getSequenceNumber());
        }
    } catch (Throwable e) {
        anSbbUsage.incrementCounterErrorSubmitMultiSmResponding(ONE);
        this.logger.severe("Error while trying to send SubmitMultiResponse=" + response, e);
    }
}
Also used : TlvConvertException(com.cloudhopper.smpp.tlv.TlvConvertException) SmppTransaction(org.restcomm.slee.resource.smpp.SmppTransaction) Address(com.cloudhopper.smpp.type.Address) UnsucessfulSME(com.cloudhopper.smpp.type.UnsucessfulSME) Esme(org.restcomm.smpp.Esme) CheckMessageLimitResult(org.restcomm.smpp.CheckMessageLimitResult) ParseException(java.text.ParseException) TlvConvertException(com.cloudhopper.smpp.tlv.TlvConvertException) RecoverablePduException(com.cloudhopper.smpp.type.RecoverablePduException) CharacterCodingException(java.nio.charset.CharacterCodingException) SmppInvalidArgumentException(com.cloudhopper.smpp.type.SmppInvalidArgumentException) PersistenceException(org.mobicents.smsc.cassandra.PersistenceException) SubmitMultiResp(com.cloudhopper.smpp.pdu.SubmitMultiResp) SmppInvalidArgumentException(com.cloudhopper.smpp.type.SmppInvalidArgumentException) Tlv(com.cloudhopper.smpp.tlv.Tlv)

Example 3 with SmppTransaction

use of org.restcomm.slee.resource.smpp.SmppTransaction in project smscgateway by RestComm.

the class TxSmppServerSbb method onDeliverSmLocal.

private void onDeliverSmLocal(final TxSmppServerSbbUsage anSbbUsage, final com.cloudhopper.smpp.pdu.DeliverSm event, final ActivityContextInterface aci) {
    SmppTransaction smppServerTransaction = (SmppTransaction) aci.getActivity();
    Esme esme = smppServerTransaction.getEsme();
    String esmeName = esme.getName();
    if (this.logger.isFineEnabled()) {
        this.logger.fine("\nReceived DELIVER_SM = " + event + " from Esme name=" + esmeName);
    }
    CheckMessageLimitResult cres = esme.onMessageReceived(1);
    if (cres.getResult() != CheckMessageLimitResult.Result.ok) {
        if (cres.getResult() == CheckMessageLimitResult.Result.firstFault) {
            this.updateOverrateCounters(cres);
            this.logger.info(cres.getMessage());
        }
        if (smscPropertiesManagement.isGenerateRejectionCdr()) {
            generateCDR(parseShortMessageText(event), esme.getNetworkId(), esme.getSystemId(), event.getSourceAddress().getAddress(), event.getSourceAddress().getTon(), event.getSourceAddress().getNpi(), event.getDestAddress().getAddress(), event.getDestAddress().getTon(), event.getDestAddress().getNpi(), CdrGenerator.CDR_SUBMIT_FAILED_ESME, cres.getMessage(), true);
        }
        DeliverSmResp response = event.createResponse();
        response.setCommandStatus(SmppConstants.STATUS_THROTTLED);
        String s = cres.getMessage();
        if (s.length() > 255)
            s = s.substring(0, 255);
        Tlv tlv;
        try {
            tlv = TlvUtil.createNullTerminatedStringTlv(SmppConstants.TAG_ADD_STATUS_INFO, s);
            response.addOptionalParameter(tlv);
        } catch (TlvConvertException e) {
            anSbbUsage.incrementCounterErrorDeliverSm(ONE);
            this.logger.severe("TlvConvertException while storing TAG_ADD_STATUS_INFO Tlv parameter", e);
        }
        // Lets send the Response with error here
        try {
            this.smppServerSessions.sendResponsePdu(esme, event, response);
        } catch (Exception e) {
            anSbbUsage.incrementCounterErrorDeliverSmResponding(ONE);
            this.logger.severe("Error while trying to send DeliverSmResponse=" + response, e);
        }
        try {
            TargetAddress ta = createDestTargetAddress(event.getDestAddress(), esme.getNetworkId());
            Sms sms = this.createSmsEvent(event, esme, ta, persistence);
            sms.setTimestampB(System.currentTimeMillis());
            generateFailureDetailedCdr(sms, EventType.IN_SMPP_REJECT_CONG, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM, SmppConstants.STATUS_THROTTLED, esme.getRemoteAddressAndPort(), event.getSequenceNumber());
        } catch (SmscProcessingException e1) {
        }
        return;
    }
    Sms sms = null;
    try {
        TargetAddress ta = createDestTargetAddress(event.getDestAddress(), esme.getNetworkId());
        sms = this.createSmsEvent(event, esme, ta, persistence);
        this.processSms(sms, persistence, esme, null, null, null, IncomingMessageType.deliver_sm, CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM, event.getSequenceNumber());
    } catch (SmscProcessingException e1) {
        anSbbUsage.incrementCounterErrorDeliverSm(ONE);
        SbbStatsUtils.handleProcessingException(e1, anSbbUsage);
        if (!e1.isSkipErrorLogging()) {
            if (e1.isIsWarning()) {
                this.logger.warning(e1.getMessage());
            } else {
                this.logger.severe(e1.getMessage(), e1);
            }
            smscStatAggregator.updateMsgInFailedAll();
        }
        if (smscPropertiesManagement.isGenerateRejectionCdr() && !e1.isMessageRejectCdrCreated()) {
            if (sms != null) {
                generateCDR(sms, CdrGenerator.CDR_SUBMIT_FAILED_ESME, e1.getMessage(), false, true);
            } else {
                generateCDR(parseShortMessageText(event), esme.getNetworkId(), esme.getSystemId(), event.getSourceAddress().getAddress(), event.getSourceAddress().getTon(), event.getSourceAddress().getNpi(), event.getDestAddress().getAddress(), event.getDestAddress().getTon(), event.getDestAddress().getNpi(), CdrGenerator.CDR_SUBMIT_FAILED_ESME, e1.getMessage(), true);
            }
        }
        DeliverSmResp response = event.createResponse();
        response.setCommandStatus(e1.getSmppErrorCode());
        String s = e1.getMessage();
        if (s != null) {
            if (s.length() > 255)
                s = s.substring(0, 255);
            Tlv tlv;
            try {
                tlv = TlvUtil.createNullTerminatedStringTlv(SmppConstants.TAG_ADD_STATUS_INFO, s);
                response.addOptionalParameter(tlv);
            } catch (TlvConvertException e) {
                this.logger.severe("TlvConvertException while storing TAG_ADD_STATUS_INFO Tlv parameter", e);
            }
        }
        // Lets send the Response with error here
        long timestampB = 0L;
        try {
            this.smppServerSessions.sendResponsePdu(esme, event, response);
            timestampB = System.currentTimeMillis();
        } catch (Exception e) {
            anSbbUsage.incrementCounterErrorDeliverSmResponding(ONE);
            this.logger.severe("Error while trying to send SubmitSmResponse=" + response, e);
        }
        EventType eventType = null;
        if (e1.getInternalErrorCode() == SmscProcessingException.INTERNAL_ERROR_STATE_OVERLOADED) {
            eventType = EventType.IN_SMPP_REJECT_CONG;
        } else {
            eventType = EventType.IN_SMPP_REJECT_FORBIDDEN;
        }
        if (sms != null) {
            sms.setTimestampB(timestampB);
            generateRejectDetailedCdr(e1.getInternalErrorCode(), sms, eventType, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM, e1.getSmppErrorCode(), esme.getRemoteAddressAndPort(), event.getSequenceNumber());
        } else {
            generateRejectDetailedCdr(e1.getInternalErrorCode(), event, esme, eventType, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM, e1.getSmppErrorCode(), parseShortMessageText(event), timestampB);
        }
        return;
    } catch (Throwable e1) {
        anSbbUsage.incrementCounterErrorDeliverSm(ONE);
        String s = "Exception when processing SubmitSm message: " + e1.getMessage();
        this.logger.severe(s, e1);
        smscStatAggregator.updateMsgInFailedAll();
        if (smscPropertiesManagement.isGenerateRejectionCdr()) {
            generateCDR(parseShortMessageText(event), esme.getNetworkId(), esme.getSystemId(), event.getSourceAddress().getAddress(), event.getSourceAddress().getTon(), event.getSourceAddress().getNpi(), event.getDestAddress().getAddress(), event.getDestAddress().getTon(), event.getDestAddress().getNpi(), CdrGenerator.CDR_SUBMIT_FAILED_ESME, e1.getMessage(), true);
        }
        DeliverSmResp response = event.createResponse();
        response.setCommandStatus(SmppConstants.STATUS_SYSERR);
        if (s.length() > 255)
            s = s.substring(0, 255);
        Tlv tlv;
        try {
            tlv = TlvUtil.createNullTerminatedStringTlv(SmppConstants.TAG_ADD_STATUS_INFO, s);
            response.addOptionalParameter(tlv);
        } catch (TlvConvertException e) {
            this.logger.severe("TlvConvertException while storing TAG_ADD_STATUS_INFO Tlv parameter", e);
        }
        // Lets send the Response with error here
        try {
            this.smppServerSessions.sendResponsePdu(esme, event, response);
            if (sms != null) {
                sms.setTimestampB(System.currentTimeMillis());
                generateFailureDetailedCdr(sms, EventType.IN_SMPP_ERROR, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM, SmppConstants.STATUS_SYSERR, esme.getRemoteAddressAndPort(), event.getSequenceNumber());
            }
        } catch (Exception e) {
            anSbbUsage.incrementCounterErrorDeliverSmResponding(ONE);
            this.logger.severe("Error while trying to send SubmitSmResponse=" + response, e);
        }
        return;
    }
    DeliverSmResp response = event.createResponse();
    // Lets send the Response with success here
    try {
        this.smppServerSessions.sendResponsePdu(esme, event, response);
        sms.setTimestampB(System.currentTimeMillis());
        generateDetailedCDR(sms, EventType.IN_SMPP_RECEIVED, CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM, SmppConstants.STATUS_OK, esme.getRemoteAddressAndPort(), event.getSequenceNumber());
    } catch (Throwable e) {
        anSbbUsage.incrementCounterErrorDeliverSmResponding(ONE);
        this.logger.severe("Error while trying to send SubmitSmResponse=" + response, e);
    }
}
Also used : TlvConvertException(com.cloudhopper.smpp.tlv.TlvConvertException) SmppTransaction(org.restcomm.slee.resource.smpp.SmppTransaction) Esme(org.restcomm.smpp.Esme) CheckMessageLimitResult(org.restcomm.smpp.CheckMessageLimitResult) ParseException(java.text.ParseException) TlvConvertException(com.cloudhopper.smpp.tlv.TlvConvertException) RecoverablePduException(com.cloudhopper.smpp.type.RecoverablePduException) CharacterCodingException(java.nio.charset.CharacterCodingException) SmppInvalidArgumentException(com.cloudhopper.smpp.type.SmppInvalidArgumentException) PersistenceException(org.mobicents.smsc.cassandra.PersistenceException) DeliverSmResp(com.cloudhopper.smpp.pdu.DeliverSmResp) Tlv(com.cloudhopper.smpp.tlv.Tlv)

Example 4 with SmppTransaction

use of org.restcomm.slee.resource.smpp.SmppTransaction in project smscgateway by RestComm.

the class RxSmppServerSbb method sendNextChunk.

private SentItem sendNextChunk(ChunkData currItem, SmsSet smsSet, Esme esme) throws SmscProcessingException {
    try {
        SmppTransaction smppServerTransaction = this.smppServerSessions.sendRequestPdu(esme, currItem.getPduRequest(), esme.getWindowWaitTimeout());
        SentItem result = new SentItem(currItem.getLocalSequenceNumber(), currItem.getPduRequest().getSequenceNumber());
        ActivityContextInterface smppTxaci = this.smppServerTransactionACIFactory.getActivityContextInterface(smppServerTransaction);
        smppTxaci.attach(this.sbbContext.getSbbLocalObject());
        return result;
    } catch (Throwable e) {
        String s = "SmscProcessingException when sending initial sendDeliverSm()=RxSmppServerSbb.sendDeliverSm(): Exception while trying to send DELIVERY Report for received SmsEvent=" + e.getMessage() + "\nsmsSet: " + smsSet + ", smsSet=" + smsSet;
        logger.severe(s, e);
        this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SC_SYSTEM_ERROR, s, EventType.OUT_SMPP_ERROR, currItem.getPduRequest().getSequenceNumber());
    }
    return null;
}
Also used : SmppTransaction(org.restcomm.slee.resource.smpp.SmppTransaction) ActivityContextInterface(javax.slee.ActivityContextInterface) SentItem(org.mobicents.smsc.slee.services.deliverysbb.SentItem)

Example 5 with SmppTransaction

use of org.restcomm.slee.resource.smpp.SmppTransaction in project smscgateway by RestComm.

the class TxSmppServerSbb method onDataSmLocal.

private void onDataSmLocal(final TxSmppServerSbbUsage anSbbUsage, final com.cloudhopper.smpp.pdu.DataSm event, ActivityContextInterface aci) {
    SmppTransaction smppServerTransaction = (SmppTransaction) aci.getActivity();
    Esme esme = smppServerTransaction.getEsme();
    String esmeName = esme.getName();
    if (this.logger.isFineEnabled()) {
        this.logger.fine("Received DATA_SM = " + event + " from Esme name=" + esmeName);
    }
    CheckMessageLimitResult cres = esme.onMessageReceived(1);
    if (cres.getResult() != CheckMessageLimitResult.Result.ok) {
        if (cres.getResult() == CheckMessageLimitResult.Result.firstFault) {
            this.updateOverrateCounters(cres);
            this.logger.info(cres.getMessage());
        }
        if (smscPropertiesManagement.isGenerateRejectionCdr()) {
            generateCDR(parseShortMessageText(event), esme.getNetworkId(), esme.getSystemId(), event.getSourceAddress().getAddress(), event.getSourceAddress().getTon(), event.getSourceAddress().getNpi(), event.getDestAddress().getAddress(), event.getDestAddress().getTon(), event.getDestAddress().getNpi(), CdrGenerator.CDR_SUBMIT_FAILED_ESME, cres.getMessage(), true);
        }
        DataSmResp response = event.createResponse();
        response.setCommandStatus(SmppConstants.STATUS_THROTTLED);
        String s = cres.getMessage();
        if (s.length() > 255)
            s = s.substring(0, 255);
        Tlv tlv;
        try {
            tlv = TlvUtil.createNullTerminatedStringTlv(SmppConstants.TAG_ADD_STATUS_INFO, s);
            response.addOptionalParameter(tlv);
        } catch (TlvConvertException e) {
            anSbbUsage.incrementCounterErrorDataSm(ONE);
            this.logger.severe("TlvConvertException while storing TAG_ADD_STATUS_INFO Tlv parameter", e);
        }
        // Lets send the Response with error here
        try {
            this.smppServerSessions.sendResponsePdu(esme, event, response);
        } catch (Exception e) {
            anSbbUsage.incrementCounterErrorDataSmResponding(ONE);
            this.logger.severe("Error while trying to send DataSmResponse=" + response, e);
        }
        try {
            TargetAddress ta = createDestTargetAddress(event.getDestAddress(), esme.getNetworkId());
            Sms sms = this.createSmsEvent(event, esme, ta, persistence);
            sms.setTimestampB(System.currentTimeMillis());
            generateFailureDetailedCdr(sms, EventType.IN_SMPP_REJECT_CONG, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_DATASM, SmppConstants.STATUS_THROTTLED, esme.getRemoteAddressAndPort(), event.getSequenceNumber());
        } catch (SmscProcessingException e1) {
        }
        return;
    }
    Sms sms = null;
    try {
        TargetAddress ta = createDestTargetAddress(event.getDestAddress(), esme.getNetworkId());
        sms = this.createSmsEvent(event, esme, ta, persistence);
        this.processSms(sms, persistence, esme, null, event, null, IncomingMessageType.data_sm, CdrDetailedGenerator.CDR_MSG_TYPE_DATASM, event.getSequenceNumber());
    } catch (SmscProcessingException e1) {
        anSbbUsage.incrementCounterErrorDataSm(ONE);
        SbbStatsUtils.handleProcessingException(e1, anSbbUsage);
        if (!e1.isSkipErrorLogging()) {
            if (e1.isIsWarning()) {
                this.logger.warning(e1.getMessage());
            } else {
                this.logger.severe(e1.getMessage(), e1);
            }
            smscStatAggregator.updateMsgInFailedAll();
        }
        if (smscPropertiesManagement.isGenerateRejectionCdr() && !e1.isMessageRejectCdrCreated()) {
            if (sms != null) {
                generateCDR(sms, CdrGenerator.CDR_SUBMIT_FAILED_ESME, e1.getMessage(), false, true);
            } else {
                generateCDR(parseShortMessageText(event), esme.getNetworkId(), esme.getSystemId(), event.getSourceAddress().getAddress(), event.getSourceAddress().getTon(), event.getSourceAddress().getNpi(), event.getDestAddress().getAddress(), event.getDestAddress().getTon(), event.getDestAddress().getNpi(), CdrGenerator.CDR_SUBMIT_FAILED_ESME, e1.getMessage(), true);
            }
        }
        DataSmResp response = event.createResponse();
        response.setCommandStatus(e1.getSmppErrorCode());
        String s = e1.getMessage();
        if (s != null) {
            if (s.length() > 255)
                s = s.substring(0, 255);
            Tlv tlv;
            try {
                tlv = TlvUtil.createNullTerminatedStringTlv(SmppConstants.TAG_ADD_STATUS_INFO, s);
                response.addOptionalParameter(tlv);
            } catch (TlvConvertException e) {
                this.logger.severe("TlvConvertException while storing TAG_ADD_STATUS_INFO Tlv parameter", e);
            }
        }
        // Lets send the Response with error here
        long timestampB = 0L;
        try {
            this.smppServerSessions.sendResponsePdu(esme, event, response);
            timestampB = System.currentTimeMillis();
        } catch (Exception e) {
            anSbbUsage.incrementCounterErrorDataSmResponding(ONE);
            this.logger.severe("Error while trying to send DataSmResponse=" + response, e);
        }
        EventType eventType = null;
        if (e1.getInternalErrorCode() == SmscProcessingException.INTERNAL_ERROR_STATE_OVERLOADED) {
            eventType = EventType.IN_SMPP_REJECT_CONG;
        } else {
            eventType = EventType.IN_SMPP_REJECT_FORBIDDEN;
        }
        if (sms != null) {
            sms.setTimestampB(System.currentTimeMillis());
            generateRejectDetailedCdr(e1.getInternalErrorCode(), sms, eventType, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_DATASM, e1.getSmppErrorCode(), esme.getRemoteAddressAndPort(), event.getSequenceNumber());
        } else {
            generateRejectDetailedCdr(e1.getInternalErrorCode(), event, esme, eventType, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM, e1.getSmppErrorCode(), parseShortMessageText(event), timestampB);
        }
        return;
    } catch (Throwable e1) {
        anSbbUsage.incrementCounterErrorDataSm(ONE);
        String s = "Exception when processing dataSm message: " + e1.getMessage();
        this.logger.severe(s, e1);
        smscStatAggregator.updateMsgInFailedAll();
        if (smscPropertiesManagement.isGenerateRejectionCdr()) {
            generateCDR(parseShortMessageText(event), esme.getNetworkId(), esme.getSystemId(), event.getSourceAddress().getAddress(), event.getSourceAddress().getTon(), event.getSourceAddress().getNpi(), event.getDestAddress().getAddress(), event.getDestAddress().getTon(), event.getDestAddress().getNpi(), CdrGenerator.CDR_SUBMIT_FAILED_ESME, e1.getMessage(), true);
        }
        DataSmResp response = event.createResponse();
        response.setCommandStatus(SmppConstants.STATUS_SYSERR);
        if (s.length() > 255)
            s = s.substring(0, 255);
        Tlv tlv;
        try {
            tlv = TlvUtil.createNullTerminatedStringTlv(SmppConstants.TAG_ADD_STATUS_INFO, s);
            response.addOptionalParameter(tlv);
        } catch (TlvConvertException e) {
            this.logger.severe("TlvConvertException while storing TAG_ADD_STATUS_INFO Tlv parameter", e);
        }
        // Lets send the Response with error here
        try {
            this.smppServerSessions.sendResponsePdu(esme, event, response);
            if (sms != null) {
                sms.setTimestampB(System.currentTimeMillis());
                generateFailureDetailedCdr(sms, EventType.IN_SMPP_ERROR, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_DATASM, SmppConstants.STATUS_SYSERR, esme.getRemoteAddressAndPort(), event.getSequenceNumber());
            }
        } catch (Exception e) {
            anSbbUsage.incrementCounterErrorDataSmResponding(ONE);
            this.logger.severe("Error while trying to send SubmitSmResponse=" + response, e);
        }
        return;
    }
    DataSmResp response = event.createResponse();
    response.setMessageId(sms.getMessageIdText());
    // Lets send the Response with success here
    try {
        if (sms.getMessageDeliveryResultResponse() == null) {
            this.smppServerSessions.sendResponsePdu(esme, event, response);
            sms.setTimestampB(System.currentTimeMillis());
            generateDetailedCDR(sms, EventType.IN_SMPP_RECEIVED, CdrDetailedGenerator.CDR_MSG_TYPE_DATASM, SmppConstants.STATUS_OK, esme.getRemoteAddressAndPort(), event.getSequenceNumber());
        }
    } catch (Exception e) {
        anSbbUsage.incrementCounterErrorDataSmResponding(ONE);
        this.logger.severe("Error while trying to send DataSmResponse=" + response, e);
    }
}
Also used : TlvConvertException(com.cloudhopper.smpp.tlv.TlvConvertException) SmppTransaction(org.restcomm.slee.resource.smpp.SmppTransaction) Esme(org.restcomm.smpp.Esme) CheckMessageLimitResult(org.restcomm.smpp.CheckMessageLimitResult) DataSmResp(com.cloudhopper.smpp.pdu.DataSmResp) ParseException(java.text.ParseException) TlvConvertException(com.cloudhopper.smpp.tlv.TlvConvertException) RecoverablePduException(com.cloudhopper.smpp.type.RecoverablePduException) CharacterCodingException(java.nio.charset.CharacterCodingException) SmppInvalidArgumentException(com.cloudhopper.smpp.type.SmppInvalidArgumentException) PersistenceException(org.mobicents.smsc.cassandra.PersistenceException) Tlv(com.cloudhopper.smpp.tlv.Tlv)

Aggregations

SmppTransaction (org.restcomm.slee.resource.smpp.SmppTransaction)5 Tlv (com.cloudhopper.smpp.tlv.Tlv)4 TlvConvertException (com.cloudhopper.smpp.tlv.TlvConvertException)4 RecoverablePduException (com.cloudhopper.smpp.type.RecoverablePduException)4 SmppInvalidArgumentException (com.cloudhopper.smpp.type.SmppInvalidArgumentException)4 CharacterCodingException (java.nio.charset.CharacterCodingException)4 ParseException (java.text.ParseException)4 PersistenceException (org.mobicents.smsc.cassandra.PersistenceException)4 CheckMessageLimitResult (org.restcomm.smpp.CheckMessageLimitResult)4 Esme (org.restcomm.smpp.Esme)4 DataSmResp (com.cloudhopper.smpp.pdu.DataSmResp)1 DeliverSmResp (com.cloudhopper.smpp.pdu.DeliverSmResp)1 SubmitMultiResp (com.cloudhopper.smpp.pdu.SubmitMultiResp)1 SubmitSmResp (com.cloudhopper.smpp.pdu.SubmitSmResp)1 Address (com.cloudhopper.smpp.type.Address)1 UnsucessfulSME (com.cloudhopper.smpp.type.UnsucessfulSME)1 Date (java.util.Date)1 ActivityContextInterface (javax.slee.ActivityContextInterface)1 SentItem (org.mobicents.smsc.slee.services.deliverysbb.SentItem)1