Search in sources :

Example 11 with SMPPSession

use of org.jsmpp.session.SMPPSession in project camel by apache.

the class SmppBindingTest method createSmppReplaceSmCommand.

@Test
public void createSmppReplaceSmCommand() {
    SMPPSession session = new SMPPSession();
    Exchange exchange = new DefaultExchange(new DefaultCamelContext());
    exchange.getIn().setHeader(SmppConstants.COMMAND, "ReplaceSm");
    SmppCommand command = binding.createSmppCommand(session, exchange);
    assertTrue(command instanceof SmppReplaceSmCommand);
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) SMPPSession(org.jsmpp.session.SMPPSession) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 12 with SMPPSession

use of org.jsmpp.session.SMPPSession in project camel by apache.

the class SmppBindingTest method createSmppQuerySmCommand.

@Test
public void createSmppQuerySmCommand() {
    SMPPSession session = new SMPPSession();
    Exchange exchange = new DefaultExchange(new DefaultCamelContext());
    exchange.getIn().setHeader(SmppConstants.COMMAND, "QuerySm");
    SmppCommand command = binding.createSmppCommand(session, exchange);
    assertTrue(command instanceof SmppQuerySmCommand);
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) SMPPSession(org.jsmpp.session.SMPPSession) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 13 with SMPPSession

use of org.jsmpp.session.SMPPSession in project dhis2-core by dhis2.

the class SMPPClient method start.

private SMPPSession start(SMPPGatewayConfig config) {
    try {
        SMPPSession session = new SMPPSession(config.getUrlTemplate(), config.getPort(), getBindParameters(config));
        log.info("SMPP client connected to SMSC: " + config.getUrlTemplate());
        return session;
    } catch (IOException e) {
        log.error("I/O error occured", e);
    }
    return null;
}
Also used : SMPPSession(org.jsmpp.session.SMPPSession) IOException(java.io.IOException)

Example 14 with SMPPSession

use of org.jsmpp.session.SMPPSession in project dhis2-core by dhis2.

the class SMPPClient method sendBatch.

public List<OutboundMessageResponse> sendBatch(OutboundMessageBatch batch, SMPPGatewayConfig config) {
    SMPPSession session = start(config);
    if (session == null) {
        return Collections.emptyList();
    }
    List<OutboundMessageResponse> responses = new ArrayList<>();
    for (OutboundMessage message : batch.getMessages()) {
        OutboundMessageResponse response = send(session, message.getText(), message.getRecipients(), config);
        responses.add(response);
    }
    stop(session);
    return responses;
}
Also used : OutboundMessage(org.hisp.dhis.outboundmessage.OutboundMessage) SMPPSession(org.jsmpp.session.SMPPSession) OutboundMessageResponse(org.hisp.dhis.outboundmessage.OutboundMessageResponse)

Example 15 with SMPPSession

use of org.jsmpp.session.SMPPSession in project dhis2-core by dhis2.

the class SMPPClient method send.

public OutboundMessageResponse send(String text, Set<String> recipients, SMPPGatewayConfig config) {
    SMPPSession session = start(config);
    if (session == null) {
        return new OutboundMessageResponse(SESSION_ERROR, GatewayResponse.SMPP_SESSION_FAILURE, false);
    }
    OutboundMessageResponse response = send(session, text, recipients, config);
    stop(session);
    return response;
}
Also used : SMPPSession(org.jsmpp.session.SMPPSession) OutboundMessageResponse(org.hisp.dhis.outboundmessage.OutboundMessageResponse)

Aggregations

SMPPSession (org.jsmpp.session.SMPPSession)15 Exchange (org.apache.camel.Exchange)8 DefaultExchange (org.apache.camel.impl.DefaultExchange)7 Test (org.junit.Test)7 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)6 BindParameter (org.jsmpp.session.BindParameter)4 IOException (java.io.IOException)3 OutboundMessageResponse (org.hisp.dhis.outboundmessage.OutboundMessageResponse)2 Date (java.util.Date)1 AxisFault (org.apache.axis2.AxisFault)1 OutboundMessage (org.hisp.dhis.outboundmessage.OutboundMessage)1 InvalidResponseException (org.jsmpp.InvalidResponseException)1 PDUException (org.jsmpp.PDUException)1 DataSm (org.jsmpp.bean.DataSm)1 OptionalParameter (org.jsmpp.bean.OptionalParameter)1 NegativeResponseException (org.jsmpp.extra.NegativeResponseException)1 ResponseTimeoutException (org.jsmpp.extra.ResponseTimeoutException)1 DataSmResult (org.jsmpp.session.DataSmResult)1 Before (org.junit.Before)1