Home » Communications » Java API for Kannel SMS/WAP gateway v 1.0.2 released

About Byron Kiourtzoglou

Byron Kiourtzoglou
Byron is a master software engineer working in the IT and Telecom domains. He is an applications developer in a wide variety of applications/services. He is currently acting as the team leader and technical architect for a proprietary service creation and integration platform for both the IT and Telecom industries in addition to a in-house big data real-time analytics solution. He is always fascinated by SOA, middleware services and mobile development. Byron is co-founder and Executive Editor at Java Code Geeks.

Java API for Kannel SMS/WAP gateway v 1.0.2 released

Hello all, we released version 1.0.2 of Java API for Kannel SMS/WAP gateway.

The latest version introduces prioritized WAP Push functionality and bulk WAP Push messaging.

You can download the new version here

An example use of the API is shown below :
 
 
 
 

public static void main(String[] args) {

 SMSManager smsManager = SMSManager.getInstance();

 // We can change the prefetch size of the background worker thread
 smsManager.setMessagesPrefetchSize(30);

 // We can change the send message rate
 smsManager.setMessagesSendRate(65);

 try {

  // Send SMS to a single destination
  smsManager.sendSMS("localhost", "13013", "foo", "bar", "sender_mobile_number", "receiver_mobile_number", "the_message");

  // Send SMS to a single destination with a specific priority and send rate
  smsManager.sendSMS("localhost", "13013", "foo", "bar", "sender_mobile_number", "receiver_mobile_number", "the_message", SMSManager.MESSAGE_PRIORITY_3);

  // Send SMS to multiple recipients
  List<String> recipientsGroupA = new ArrayList<String>();
  recipientsGroupA.add("receiver_mobile_number_1");
  recipientsGroupA.add("receiver_mobile_number_2");
  recipientsGroupA.add("receiver_mobile_number_3");
  recipientsGroupA.add("receiver_mobile_number_4");
  recipientsGroupA.add("receiver_mobile_number_5");
  smsManager.sendSMS("localhost", "13013", "foo", "bar", "sender_mobile_number", recipientsGroupA, "the_message");

  // Send SMS to multiple recipients with a specific priority and send rate
  List<String> recipientsGroupB = new ArrayList<String>();
  recipientsGroupB.add("receiver_mobile_number_1");
  recipientsGroupB.add("receiver_mobile_number_2");
  recipientsGroupB.add("receiver_mobile_number_3");
  recipientsGroupB.add("receiver_mobile_number_4");
  recipientsGroupB.add("receiver_mobile_number_5");
  smsManager.sendBulkSMS("localhost", "13013", "foo", "bar", "sender_mobile_number", recipientsGroupB, "the_message", SMSManager.MESSAGE_PRIORITY_7);

  // Send a WAP Push request to a single mobile recipient
  smsManager.sendWAPPush("localhost", "8181", "receiver_mobile_number", SMSManager.WAP_PUSH_RECEIVER_TYPE_MOBILE, "the_message", "http://localhost", 3);

  // Send a WAP Push request to a single destination with a specific priority and send rate
  smsManager.sendWAPPush("localhost", "8181", "receiver_mobile_number", SMSManager.WAP_PUSH_RECEIVER_TYPE_MOBILE, "the_message", "http://localhost", 3, SMSManager.MESSAGE_PRIORITY_8);

  // Send WAP Push request to multiple recipients with a specific priority and send rate
  List<String> recipientsGroupC = new ArrayList<String>();
  recipientsGroupC.add("receiver_mobile_number_1");
  recipientsGroupC.add("receiver_mobile_number_2");
  recipientsGroupC.add("receiver_mobile_number_3");
  recipientsGroupC.add("receiver_mobile_number_4");
  recipientsGroupC.add("receiver_mobile_number_5");
  smsManager.sendBulkWAPPush("localhost", "8181", recipientsGroupC, SMSManager.WAP_PUSH_RECEIVER_TYPE_MOBILE, "the_message", "http://localhost", 3, SMSManager.MESSAGE_PRIORITY_8);

 } catch (Exception ex) {
  ex.printStackTrace();
 }

 // Stops the background worker.
 // smsManager.stopSMSManagerWorker();

}

Best Regards

Justin

Related articles :

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design

and many more ....

 

15 comments

  1. Hi Justin,

    Can you please explain the steps required to configure the API. What all needs to be deployed on local machine on the port 13013 and all. I try to ran this example but as port 13013 on my local machine was not being listened by any program the socket connection failed.

    Thanx,
    X.

  2. Can you tell me how to use a send sms function with DLR..

  3. Please help me!
    I use:

    // Send a WAP Push request to a single mobile recipient
    smsManager.sendWAPPush(“localhost”, “8181”, “receiver_mobile_number”, SMSManager.WAP_PUSH_RECEIVER_TYPE_MOBILE, “the_message”, “http://localhost”, 3);

    But
    My errors:
    java.io.FileNotFoundException: http://localhost:8080/wappush
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at com.javacodegeeks.kannel.api.SMSManager.sendWAPPush(SMSManager.java:793)
    at com.javacodegeeks.kannel.api.SMSManager.sendWAPPush(SMSManager.java:708)

    Thanks!

    • Sorry, I’m using:
      // Send a WAP Push request to a single mobile recipient
      smsManager.sendWAPPush(“localhost”, “8080″, “receiver_mobile_number”, SMSManager.WAP_PUSH_RECEIVER_TYPE_MOBILE, “the_message”, “http://localhost”, 3);

  4. HI ,

    I am kannel sms API in my java application
    smsManager.sendSMS(“localhost”, “9080”, “foo”, “bar”, “send_number”, “rec_number”, “Hi Test”);

    I am getting below exception
    java.net.ConnectException: Connection refused: connect.

    please help to configure kannel sms api.

    Thanks.

  5. 1)Send SMS with priority is not been sent to the SMPPsim that has been configured. SMS send without priority are submitted to the SMSC with no issues. Can anyone revert back on this, as on what need to be done to submit sms with priority.

    2)How to get the delivery status if the submitted message from this program to the kannel router?

    thanks.

  6. hi how can i get replay message (MO) from this api

  7. Hi, how to get Kannel Maven dependency?

  8. Where is SMSManager File.? Please Help ME…

  9. Now I’m getting this error

    java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    at java.net.Socket.connect(Socket.java:528)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
    at sun.net.www.http.HttpClient.(HttpClient.java:211)
    at sun.net.www.http.HttpClient.New(HttpClient.java:308)
    at sun.net.www.http.HttpClient.New(HttpClient.java:326)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:996)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:932)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:850)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300)
    at com.javacodegeeks.kannel.api.SMSManager.sendSMS(SMSManager.java:357)
    at com.javacodegeeks.kannel.api.SMSManager.sendSMS(SMSManager.java:128)
    at sendSMS.main(Sms1.java:26)

Leave a Reply

Your email address will not be published. Required fields are marked *

*


1 + two =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close