Communications

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 :

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.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

16 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Xander
Xander
11 years ago

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.

Mitesh Patel
Mitesh Patel
10 years ago

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

Albert
Albert
10 years ago

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!

Albert
Albert
10 years ago
Reply to  Albert

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);

Byron Kiourtzoglou
10 years ago
Reply to  Albert

Hello Albert,

Please check if Kannel WAP gateway process is installed and running on your local machine. The java.io.FileNotFoundException: http://localhost:8080/wappush exceptions shows that Kannel is not running localy.

BRs
Byron

Albert
Albert
10 years ago

Hello Byron Kiourtzoglou,
Thank for supports.
I’ve tried running the Kannel WAP gateway (kannel.api-1.0.2.jar)
but it appears errors: Failed to load Main-Class manifest attribute from …

Please tell me how to run Kannel WAP gateway

BRs
Albert

Albert
Albert
10 years ago

Thank for supports.
I’ve tried running the Kannel WAP gateway (kannel.api-1.0.2.jar)
but it appears errors: Failed to load Main-Class manifest attribute from …

Please tell me how to run Kannel WAP gateway.

BRs
Albert

Albert
Albert
10 years ago
Reply to  Albert

Hi Byron,
I’ve tried: Run jar in command line on Windows 7 – 32 (Classpath)

BRs
Albert

Albert
Albert
10 years ago
Reply to  Albert

Please help me Mr. Byron

raju
raju
10 years ago

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.

kishore
kishore
10 years ago

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.

hemanth
hemanth
10 years ago

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

Etapo
Etapo
10 years ago

Hi, how to get Kannel Maven dependency?

Mehdi
Mehdi
9 years ago

Where is SMSManager File.? Please Help ME…

Mehdi
Mehdi
9 years ago

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)

leonardo
leonardo
7 years ago

pls, explain how to setup Kannel correctly

java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.javacodegeeks.kannel.api.SMSManager.sendSMS(SMSManager.java:357)
at com.javacodegeeks.kannel.api.SMSManager.sendSMS(SMSManager.java:128)
at com.sms.app.senderSms.main(senderSms.java:23)

Back to top button