Search in sources :

Example 1 with DeliverSmResp

use of com.cloudhopper.smpp.pdu.DeliverSmResp 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 2 with DeliverSmResp

use of com.cloudhopper.smpp.pdu.DeliverSmResp in project smscgateway by RestComm.

the class RxSmppServerSbbTest method testSubmitSm_test3_3.

@Test(groups = { "RxSmppServer" })
public void testSubmitSm_test3_3() throws Exception {
    if (!this.cassandraDbInited)
        return;
    ArrayList<SmsDef> lst = new ArrayList<SmsDef>();
    SmsDef sd1 = new SmsDef();
    String s01 = "1234567890";
    StringBuilder sb = new StringBuilder();
    for (int i1 = 0; i1 < 20; i1++) {
        sb.append(s01);
    }
    sd1.msg = sb.toString();
    sd1.stored = true;
    lst.add(sd1);
    SmsDef sd2 = new SmsDef();
    sd2.msg = "Msg 2";
    sd2.stored = true;
    lst.add(sd2);
    SmsSet smsSet = prepareDatabase(lst);
    SmsSetEvent event = new SmsSetEvent();
    event.setSmsSet(smsSet);
    EventContext eventContext = null;
    ActivityContextInterface aci = new SmppTransactionProxy(esme);
    this.sbb.onDeliverSm(event, aci, eventContext);
    DeliverSmResp eventResp = new DeliverSmResp();
    eventResp.setSequenceNumber(sbb.getNextSentSequenseId());
    this.sbb.onDeliverSmRespParent(eventResp, aci, eventContext);
    eventResp = new DeliverSmResp();
    eventResp.setSequenceNumber(sbb.getNextSentSequenseId());
    this.sbb.onDeliverSmRespParent(eventResp, aci, eventContext);
    eventResp = new DeliverSmResp();
    eventResp.setSequenceNumber(sbb.getNextSentSequenseId());
    this.sbb.onDeliverSmRespParent(eventResp, aci, eventContext);
}
Also used : EventContext(javax.slee.EventContext) SmsSetEvent(org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent) ActivityContextInterface(javax.slee.ActivityContextInterface) ArrayList(java.util.ArrayList) SmsSet(org.mobicents.smsc.library.SmsSet) DeliverSmResp(com.cloudhopper.smpp.pdu.DeliverSmResp) Test(org.testng.annotations.Test)

Example 3 with DeliverSmResp

use of com.cloudhopper.smpp.pdu.DeliverSmResp in project smscgateway by RestComm.

the class RxSmppServerSbbTest method testSubmitSm_test3_2.

@Test(groups = { "RxSmppServer" })
public void testSubmitSm_test3_2() throws Exception {
    if (!this.cassandraDbInited)
        return;
    ArrayList<SmsDef> lst = new ArrayList<SmsDef>();
    SmsDef sd1 = new SmsDef();
    sd1.msg = "Msg 1";
    sd1.stored = true;
    lst.add(sd1);
    SmsDef sd2 = new SmsDef();
    sd2.msg = "Msg 2";
    sd2.stored = true;
    lst.add(sd2);
    SmsDef sd3 = new SmsDef();
    sd3.msg = "Msg 3";
    sd3.stored = true;
    lst.add(sd3);
    SmsSet smsSet = prepareDatabase(lst);
    SmsSetEvent event = new SmsSetEvent();
    event.setSmsSet(smsSet);
    EventContext eventContext = null;
    ActivityContextInterface aci = new SmppTransactionProxy(esme);
    this.sbb.onDeliverSm(event, aci, eventContext);
    DeliverSmResp eventResp = new DeliverSmResp();
    eventResp.setSequenceNumber(sbb.getNextSentSequenseId());
    this.sbb.onDeliverSmRespParent(eventResp, aci, eventContext);
    eventResp = new DeliverSmResp();
    // eventResp.setCommandStatus(2);
    eventResp.setSequenceNumber(sbb.getNextSentSequenseId());
    // eventResp.setSequenceNumber(10001);
    this.sbb.onDeliverSmRespParent(eventResp, aci, eventContext);
    eventResp = new DeliverSmResp();
    eventResp.setSequenceNumber(sbb.getNextSentSequenseId());
    this.sbb.onPduRequestTimeoutParent(null, aci, eventContext);
// this.sbb.onDeliverSmResp(eventResp, aci, eventContext);
}
Also used : EventContext(javax.slee.EventContext) SmsSetEvent(org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent) ActivityContextInterface(javax.slee.ActivityContextInterface) ArrayList(java.util.ArrayList) SmsSet(org.mobicents.smsc.library.SmsSet) DeliverSmResp(com.cloudhopper.smpp.pdu.DeliverSmResp) Test(org.testng.annotations.Test)

Example 4 with DeliverSmResp

use of com.cloudhopper.smpp.pdu.DeliverSmResp in project smscgateway by RestComm.

the class RxSmppServerSbbTest method testSubmitSm_test1_2.

@Test(groups = { "RxSmppServer" })
public void testSubmitSm_test1_2() throws Exception {
    if (!this.cassandraDbInited)
        return;
    ArrayList<SmsDef> lst = new ArrayList<SmsDef>();
    SmsDef sd1 = new SmsDef();
    sd1.stored = true;
    lst.add(sd1);
    SmsSet smsSet = prepareDatabase(lst);
    SmsSetEvent event = new SmsSetEvent();
    event.setSmsSet(smsSet);
    EventContext eventContext = null;
    ActivityContextInterface aci = new SmppTransactionProxy(esme);
    this.sbb.onDeliverSm(event, aci, eventContext);
    DeliverSmResp eventResp = new DeliverSmResp();
    eventResp.setSequenceNumber(sbb.getNextSentSequenseId());
    this.sbb.onDeliverSmRespParent(eventResp, aci, eventContext);
}
Also used : EventContext(javax.slee.EventContext) SmsSetEvent(org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent) ActivityContextInterface(javax.slee.ActivityContextInterface) ArrayList(java.util.ArrayList) SmsSet(org.mobicents.smsc.library.SmsSet) DeliverSmResp(com.cloudhopper.smpp.pdu.DeliverSmResp) Test(org.testng.annotations.Test)

Example 5 with DeliverSmResp

use of com.cloudhopper.smpp.pdu.DeliverSmResp in project smscgateway by RestComm.

the class RxSmppServerSbbTest method testSubmitSm_test1.

@Test(groups = { "RxSmppServer" })
public void testSubmitSm_test1() throws Exception {
    if (!this.cassandraDbInited)
        return;
    ArrayList<SmsDef> lst = new ArrayList<SmsDef>();
    SmsDef sd1 = new SmsDef();
    lst.add(sd1);
    SmsSet smsSet = prepareDatabase(lst);
    SmsSetEvent event = new SmsSetEvent();
    event.setSmsSet(smsSet);
    EventContext eventContext = null;
    ActivityContextInterface aci = new SmppTransactionProxy(esme);
    this.sbb.onDeliverSm(event, aci, eventContext);
    DeliverSmResp eventResp = new DeliverSmResp();
    eventResp.setSequenceNumber(sbb.getNextSentSequenseId());
    this.sbb.onDeliverSmRespParent(eventResp, aci, eventContext);
}
Also used : EventContext(javax.slee.EventContext) SmsSetEvent(org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent) ActivityContextInterface(javax.slee.ActivityContextInterface) ArrayList(java.util.ArrayList) SmsSet(org.mobicents.smsc.library.SmsSet) DeliverSmResp(com.cloudhopper.smpp.pdu.DeliverSmResp) Test(org.testng.annotations.Test)

Aggregations

DeliverSmResp (com.cloudhopper.smpp.pdu.DeliverSmResp)5 ArrayList (java.util.ArrayList)4 ActivityContextInterface (javax.slee.ActivityContextInterface)4 EventContext (javax.slee.EventContext)4 SmsSet (org.mobicents.smsc.library.SmsSet)4 SmsSetEvent (org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent)4 Test (org.testng.annotations.Test)4 Tlv (com.cloudhopper.smpp.tlv.Tlv)1 TlvConvertException (com.cloudhopper.smpp.tlv.TlvConvertException)1 RecoverablePduException (com.cloudhopper.smpp.type.RecoverablePduException)1 SmppInvalidArgumentException (com.cloudhopper.smpp.type.SmppInvalidArgumentException)1 CharacterCodingException (java.nio.charset.CharacterCodingException)1 ParseException (java.text.ParseException)1 PersistenceException (org.mobicents.smsc.cassandra.PersistenceException)1 SmppTransaction (org.restcomm.slee.resource.smpp.SmppTransaction)1 CheckMessageLimitResult (org.restcomm.smpp.CheckMessageLimitResult)1 Esme (org.restcomm.smpp.Esme)1