View Javadoc

1   package org.kuali.ole.deliver.batch;
2   
3   import org.apache.camel.Exchange;
4   import org.apache.camel.ExchangePattern;
5   import org.apache.camel.component.smpp.SmppConfiguration;
6   import org.apache.camel.component.smpp.SmppConstants;
7   import org.apache.camel.component.smpp.SmppSubmitSmCommand;
8   import org.apache.camel.impl.DefaultCamelContext;
9   import org.apache.camel.impl.DefaultExchange;
10  import org.jsmpp.bean.*;
11  import org.jsmpp.session.SMPPSession;
12  
13  import java.util.Date;
14  
15  /**
16   * Created with IntelliJ IDEA.
17   * User: ?
18   * Date: 1/16/13
19   * Time: 7:08 PM
20   * To change this template use File | Settings | File Templates.
21   */
22  public class OleSms  {
23      private SMPPSession session;
24  
25      private SmppConfiguration config = new SmppConfiguration();;
26      private SmppSubmitSmCommand command = new SmppSubmitSmCommand(session, config);
27  
28  
29      public void sendSms(String from,String to,String message){
30          Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
31          exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitSm");
32          exchange.getIn().setHeader(SmppConstants.ID, "1");
33          exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR_TON, TypeOfNumber.INTERNATIONAL.value());
34          exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR_NPI, NumberingPlanIndicator.ISDN.value());
35          exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR,from);
36          exchange.getIn().setHeader(SmppConstants.DEST_ADDR_TON, TypeOfNumber.INTERNATIONAL.value());
37          exchange.getIn().setHeader(SmppConstants.DEST_ADDR_NPI, NumberingPlanIndicator.ISDN.value());
38          exchange.getIn().setHeader(SmppConstants.DEST_ADDR,to);
39          exchange.getIn().setHeader(SmppConstants.SCHEDULE_DELIVERY_TIME, new Date(1111111));
40          exchange.getIn().setHeader(SmppConstants.VALIDITY_PERIOD, new Date(2222222));
41          exchange.getIn().setHeader(SmppConstants.PROTOCOL_ID, (byte) 1);
42          exchange.getIn().setHeader(SmppConstants.PRIORITY_FLAG, (byte) 2);
43          exchange.getIn().setHeader(SmppConstants.REGISTERED_DELIVERY, new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS).value());
44          exchange.getIn().setHeader(SmppConstants.REPLACE_IF_PRESENT_FLAG, ReplaceIfPresentFlag.REPLACE.value());
45          exchange.getIn().setBody(message);
46  
47          try{
48              command.execute(exchange);
49          }catch(Exception e){
50  
51          }
52      }
53  
54  }