Search in sources :

Example 1 with ResponseTimeoutException

use of org.jsmpp.extra.ResponseTimeoutException in project dhis2-core by dhis2.

the class SMPPClient method send.

// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
private OutboundMessageResponse send(SMPPSession session, String text, Set<String> recipients, SMPPGatewayConfig config) {
    OutboundMessageResponse response = new OutboundMessageResponse();
    SubmitMultiResult result = null;
    try {
        result = session.submitMultiple(config.getSystemType(), config.getTypeOfNumber(), config.getNumberPlanIndicator(), SOURCE, getAddresses(recipients), new ESMClass(), (byte) 0, (byte) 1, TIME_FORMATTER.format(new Date()), null, new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE), ReplaceIfPresentFlag.DEFAULT, new GeneralDataCoding(Alphabet.ALPHA_DEFAULT, MessageClass.CLASS1, config.isCompressed()), (byte) 0, text.getBytes());
        log.info(String.format("Messages submitted, result is %s", result.getMessageId()));
    } catch (PDUException e) {
        log.error("Invalid PDU parameter", e);
    } catch (ResponseTimeoutException e) {
        log.error("Response timeout", e);
    } catch (InvalidResponseException e) {
        log.error("Receive invalid response", e);
    } catch (NegativeResponseException e) {
        log.error("Receive negative response", e);
    } catch (IOException e) {
        log.error("I/O error", e);
    } catch (Exception e) {
        log.error("Exception in submitting SMPP request", e);
    }
    if (result != null) {
        if (result.getUnsuccessDeliveries() == null || result.getUnsuccessDeliveries().length == 0) {
            log.info("Message pushed to broker successfully");
            response.setOk(true);
            response.setDescription(result.getMessageId());
            response.setResponseObject(GatewayResponse.RESULT_CODE_0);
        } else {
            String failureCause = DeliveryReceiptState.valueOf(result.getUnsuccessDeliveries()[0].getErrorStatusCode()) + " - " + result.getMessageId();
            log.error(failureCause);
            response.setDescription(failureCause);
            response.setResponseObject(GatewayResponse.FAILED);
        }
    } else {
        response.setDescription(SENDING_FAILED);
        response.setResponseObject(GatewayResponse.FAILED);
    }
    return response;
}
Also used : ResponseTimeoutException(org.jsmpp.extra.ResponseTimeoutException) PDUException(org.jsmpp.PDUException) IOException(java.io.IOException) NegativeResponseException(org.jsmpp.extra.NegativeResponseException) IOException(java.io.IOException) ResponseTimeoutException(org.jsmpp.extra.ResponseTimeoutException) InvalidResponseException(org.jsmpp.InvalidResponseException) PDUException(org.jsmpp.PDUException) OutboundMessageResponse(org.hisp.dhis.outboundmessage.OutboundMessageResponse) InvalidResponseException(org.jsmpp.InvalidResponseException) NegativeResponseException(org.jsmpp.extra.NegativeResponseException)

Aggregations

IOException (java.io.IOException)1 OutboundMessageResponse (org.hisp.dhis.outboundmessage.OutboundMessageResponse)1 InvalidResponseException (org.jsmpp.InvalidResponseException)1 PDUException (org.jsmpp.PDUException)1 NegativeResponseException (org.jsmpp.extra.NegativeResponseException)1 ResponseTimeoutException (org.jsmpp.extra.ResponseTimeoutException)1