use of com.cloudhopper.smpp.pdu.DataSmResp in project smscgateway by RestComm.
the class MessageDeliveryResultResponseSmpp method responseDeliverySuccess.
@Override
public void responseDeliverySuccess() {
PduResponse response = null;
BaseSm event = null;
if (eventSubmit != null) {
event = eventSubmit;
SubmitSmResp responseSubmit = eventSubmit.createResponse();
response = responseSubmit;
responseSubmit.setMessageId(((Long) messageId).toString());
}
if (eventData != null) {
event = eventData;
DataSmResp responseData = eventData.createResponse();
response = responseData;
responseData.setMessageId(((Long) messageId).toString());
}
// Lets send the Response with success here
try {
if (response != null) {
this.smppSessions.sendResponsePdu(esme, event, response);
}
} catch (Throwable e) {
this.logger.severe("Error while trying to send SubmitSmResponse=" + response, e);
}
}
use of com.cloudhopper.smpp.pdu.DataSmResp in project smscgateway by RestComm.
the class MessageDeliveryResultResponseSmpp method responseDeliveryFailure.
@Override
public void responseDeliveryFailure(DeliveryFailureReason reason, MAPErrorMessage errMessage) {
PduResponse response = null;
BaseSm event = null;
if (eventSubmit != null) {
event = eventSubmit;
SubmitSmResp responseSubmit = eventSubmit.createResponse();
response = responseSubmit;
responseSubmit.setMessageId(((Long) messageId).toString());
}
if (eventData != null) {
event = eventData;
DataSmResp responseData = eventData.createResponse();
response = responseData;
responseData.setMessageId(((Long) messageId).toString());
}
response.setCommandStatus(SmppConstants.STATUS_DELIVERYFAILURE);
if (reason != null) {
byte[] value = new byte[1];
value[0] = (byte) reason.getCode();
Tlv tlv = new Tlv(SmppConstants.TAG_DELIVERY_FAILURE_REASON, value);
response.addOptionalParameter(tlv);
}
// Lets send the Response with success here
try {
if (response != null) {
this.smppSessions.sendResponsePdu(esme, event, response);
}
} catch (Throwable e) {
this.logger.severe("Error while trying to send SubmitSmResponse=" + response, e);
}
}
use of com.cloudhopper.smpp.pdu.DataSmResp 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);
}
}
Aggregations