use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class MtSbb method onRejectComponent.
@Override
public void onRejectComponent(RejectComponent event, ActivityContextInterface aci) {
try {
super.onRejectComponent(event, aci);
String reason = this.getRejectComponentReason(event);
SmsSet smsSet = getSmsSet();
if (smsSet == null) {
logger.severe("MtSbb.onRejectComponent(): CMP smsSet is missed");
markDeliveringIsEnded(true);
return;
}
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.HLR_REJECT_AFTER_ROUTING_INFO, "onRejectComponent after MtForwardSM Request: " + reason != null ? reason.toString() : "", true, null, false, ProcessingType.SS7_MT);
} catch (Throwable e1) {
logger.severe("Exception in MtSbb.onDialogProviderAbort() when fetching records and issuing events: " + e1.getMessage(), e1);
markDeliveringIsEnded(true);
}
}
use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class MtSbb method setupMtForwardShortMessageRequest.
// *********
// Main service methods
public void setupMtForwardShortMessageRequest(ISDNAddressString networkNode, String imsiData, LMSI lmsi, int networkId) {
if (this.logger.isFineEnabled()) {
this.logger.fine("\nmperforming setupMtForwardShortMessageRequest ISDNAddressString= " + networkNode);
}
SmsSet smsSet = getSmsSet();
if (smsSet == null) {
markDeliveringIsEnded(true);
logger.severe("MtSbb.setupMtForwardShortMessageRequest(): CMP smsSet is missed");
return;
}
Sms sms0 = smsSet.getSms(0);
Integer mtRemoteSccpTt = sms0.getMtRemoteSccpTt();
SccpAddress networkNodeSccpAddress = this.getMSCSccpAddress(networkNode, mtRemoteSccpTt);
IMSI imsi = this.mapParameterFactory.createIMSI(imsiData);
SM_RP_DA sm_RP_DA = this.mapParameterFactory.createSM_RP_DA(imsi);
AddressString scAddress = this.getServiceCenterAddressString(networkId);
SM_RP_OA sm_RP_OA = this.mapParameterFactory.createSM_RP_OA_ServiceCentreAddressOA(scAddress);
if (sms0 != null) {
// we only set it for first sms in the list
sms0.setMtServiceCenterAddress(scAddress.getAddress());
}
this.setNnn(networkNode);
this.setNetworkNode(networkNodeSccpAddress);
this.setSmRpDa(sm_RP_DA);
this.setSmRpOa(sm_RP_OA);
// Set cache with MAP version
MAPApplicationContextVersion mapApplicationContextVersion = mapVersionCache.getMAPApplicationContextVersion(networkNode.getAddress());
if (mapApplicationContextVersion == null) {
mapApplicationContextVersion = MAPApplicationContextVersion.getInstance(smscPropertiesManagement.getMaxMapVersion());
} else {
this.setNegotiatedMapVersionUsing(true);
}
this.setMAPVersionTested(mapApplicationContextVersion);
// dropaftersri mproc rules
try {
if (this.getTotalUnsentMessageCount() > 0) {
ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
ArrayList<Sms> lstRerouted = new ArrayList<Sms>();
ArrayList<Integer> lstNewNetworkId = new ArrayList<Integer>();
TargetAddress lock = persistence.obtainSynchroObject(new TargetAddress(smsSet));
try {
synchronized (lock) {
this.applyMprocRulesOnImsiResponse(smsSet, lstPermFailured, lstRerouted, lstNewNetworkId, networkNode, imsiData);
this.onImsiDrop(smsSet, lstPermFailured, lstRerouted, lstNewNetworkId, networkNode, imsiData);
}
} finally {
persistence.releaseSynchroObject(lock);
}
}
} catch (Throwable e) {
}
if (this.getTotalUnsentMessageCount() == 0) {
setupReportSMDeliveryStatusRequestSuccess(smsSet, true);
smsSet.setStatus(ErrorCode.SUCCESS);
this.markDeliveringIsEnded(true);
} else {
try {
this.sendMtSms(this.getMtFoSMSMAPApplicationContext(mapApplicationContextVersion), MessageProcessingState.firstMessageSending, null, smsSet.getNetworkId());
} catch (SmscProcessingException e) {
String reason = "SmscPocessingException when invoking sendMtSms() from setupMtForwardShortMessageRequest()-firstMessageSending: " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
try {
smStatus = ErrorCode.fromInt(e.getSmppErrorCode());
} catch (IllegalArgumentException e1) {
}
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
} catch (Throwable e) {
String reason = "Exception when invoking sendMtSms() from setupMtForwardShortMessageRequest()-firstMessageSending: " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
}
}
}
use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class MtSbb method onSendMt.
// *********
// initial event
public void onSendMt(SendMtEvent event, ActivityContextInterface aci, EventContext eventContext) {
SmsSet smsSet = event.getSmsSet();
this.addInitialMessageSet(smsSet, event.getCurrentMsgNum());
this.setInformServiceCenterContainer(event.getInformServiceCenterContainer());
this.setSriMapVersion(event.getSriMapVersion());
this.setDeliveryTimerID(event.getTimerID());
setupMtForwardShortMessageRequest(event.getNetworkNode(), event.getImsiData(), event.getLmsi(), smsSet.getNetworkId());
}
use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class MtSbb method onDialogProviderAbort.
@Override
public void onDialogProviderAbort(DialogProviderAbort evt, ActivityContextInterface aci) {
try {
super.onDialogProviderAbort(evt, aci);
MAPAbortProviderReason abortProviderReason = evt.getAbortProviderReason();
SmsSet smsSet = getSmsSet();
if (smsSet == null) {
logger.severe("MtSbb.onDialogProviderAbort(): CMP smsSet is missed");
markDeliveringIsEnded(true);
return;
}
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.MSC_REFUSES_SM, "onDialogProviderAbort after MtForwardSM Request: " + abortProviderReason != null ? abortProviderReason.toString() : "", true, null, false, ProcessingType.SS7_MT);
} catch (Throwable e1) {
logger.severe("Exception in MtSbb.onDialogProviderAbort() when fetching records and issuing events: " + e1.getMessage(), e1);
markDeliveringIsEnded(true);
}
}
use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class MtSbb method handleSmsResponse.
private void handleSmsResponse(MAPDialogSms mapDialogSms, boolean continueDialog) {
SmsSet smsSet = getSmsSet();
if (smsSet == null) {
logger.severe("MtSbb.handleSmsResponse(): CMP smsSet is missed");
markDeliveringIsEnded(true);
return;
}
smscStatAggregator.updateMsgOutSentAll();
smscStatAggregator.updateMsgOutSentSs7();
Sms sms = this.getMessageInSendingPool(0);
// checking if there are yet message segments
int messageSegmentNumber = this.getMessageSegmentNumber();
SmsSignalInfo[] segments = this.getSegments();
if (segments != null && messageSegmentNumber < segments.length - 1) {
this.generateCDR(sms, CdrGenerator.CDR_PARTIAL, CdrGenerator.CDR_SUCCESS_NO_REASON, true, false, messageSegmentNumber);
// we have more message parts to be sent yet
messageSegmentNumber++;
this.setMessageSegmentNumber(messageSegmentNumber);
try {
smscStatAggregator.updateMsgOutTryAll();
smscStatAggregator.updateMsgOutTrySs7();
this.sendMtSms(mapDialogSms.getApplicationContext(), MessageProcessingState.nextSegmentSending, continueDialog ? mapDialogSms : null, smsSet.getNetworkId());
return;
} catch (SmscProcessingException e) {
this.logger.severe("SmscPocessingException when invoking sendMtSms() from handleSmsResponse()-nextSegmentSending: " + e.toString(), e);
this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SYSTEM_FAILURE, "Error sendMtSms in handleSmsResponse(): ", true, null, false, ProcessingType.SS7_MT);
return;
}
}
// current message is sent
// firstly sending of a positive response for transactional mode
this.sendTransactionalResponseSuccess(sms);
// mproc rules applying for delivery phase
this.applyMprocRulesOnSuccess(sms, ProcessingType.SS7_MT);
// Processing succeeded
sms.getSmsSet().setStatus(ErrorCode.SUCCESS);
this.postProcessSucceeded(sms, null, null);
// success CDR generating
boolean isPartial = MessageUtil.isSmsNotLastSegment(sms);
this.generateCDR(sms, isPartial ? CdrGenerator.CDR_PARTIAL : CdrGenerator.CDR_SUCCESS, CdrGenerator.CDR_SUCCESS_NO_REASON, segments != null, true, messageSegmentNumber);
// adding a success receipt if it is needed
this.generateSuccessReceipt(smsSet, sms);
TargetAddress lock = persistence.obtainSynchroObject(new TargetAddress(smsSet));
try {
synchronized (lock) {
// marking the message in cache as delivered
this.commitSendingPoolMsgCount();
// now we are trying to sent other messages
sms = obtainNextMessage(ProcessingType.SS7_MT);
if (sms != null) {
// dropaftersri pmproc rules
ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
ArrayList<Sms> lstRerouted = new ArrayList<Sms>();
ArrayList<Integer> lstNewNetworkId = new ArrayList<Integer>();
SM_RP_DA da = this.getSmRpDa();
ISDNAddressString networkNodeNumber = this.getNnn();
this.applyMprocRulesOnImsiResponse(smsSet, lstPermFailured, lstRerouted, lstNewNetworkId, networkNodeNumber, da.getIMSI().getData());
this.onImsiDrop(smsSet, lstPermFailured, lstRerouted, lstNewNetworkId, networkNodeNumber, da.getIMSI().getData());
}
sms = this.getMessageInSendingPool(0);
if (sms != null) {
try {
// sms.setDeliveryCount(sms.getDeliveryCount() + 1);
smscStatAggregator.updateMsgOutTryAll();
smscStatAggregator.updateMsgOutTrySs7();
this.sendMtSms(mapDialogSms.getApplicationContext(), MessageProcessingState.firstMessageSending, continueDialog ? mapDialogSms : null, smsSet.getNetworkId());
return;
} catch (SmscProcessingException e) {
this.logger.severe("SmscPocessingException when invoking sendMtSms() from handleSmsResponse(): " + e.toString(), e);
}
}
// more messages in a database
if (continueDialog) {
try {
mapDialogSms.close(false);
} catch (MAPException e) {
this.logger.severe("MAPException when closing MAP dialog from handleSmsResponse(): " + e.toString(), e);
}
}
// no more messages to send - remove smsSet
setupReportSMDeliveryStatusRequestSuccess(smsSet, mapDialogSms.getApplicationContext().getApplicationContextVersion() != MAPApplicationContextVersion.version1);
smsSet.setStatus(ErrorCode.SUCCESS);
this.markDeliveringIsEnded(true);
// this.freeSmsSetSucceded(smsSet, pers);
}
} finally {
persistence.releaseSynchroObject(lock);
}
}
Aggregations