wood burning stoves 2.0*
The moose likes Java in General and the fly likes sms gateway(queue sms) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "sms gateway(queue sms)" Watch "sms gateway(queue sms)" New topic
Author

sms gateway(queue sms)

siti aisya
Greenhorn

Joined: Aug 18, 2008
Posts: 3
I currently doing a java program on SMS Gateway where we can send and receive SMS using the GSM modem. We could send SMS from the website that is control by our admin. Once our admin send the broadcast question to registered users. We also set a specific format to our receive sms. Then the registered users can reply back answer to us. Then if the reply is in the correct or wrong format, we will send an auto reply. Now, my problem is the gateway sometimes jammed because it have to handle both receiving and sending sms at the same time.

I planned to use queue method(Linked List) to queue up the sms.I plan to queue the sending sms first before the gateway process the receiving sms.

I currently stuck with this.I tried using the following code:

Queue<SMSMessage> smsQueue = new LinkedList<SMSMessage>();
......
......
public void run() {
while(true) {
// peek at the head of the queue, but don't grab it
Object pull = smsQueue.peek();
SMSMessage enqueued = null;
// grab the head of the queue
if (pull!=null) {
enqueued = smsQueue.poll();
System.out.println("Enqueued successful");

//send the message here
String num = enqueued.getPhoneNo();
String msg = enqueued.getMessage();


Please help me... thanks alot..
ram kumar
Ranch Hand

Joined: May 22, 2008
Posts: 146
Originally posted by siti aisya:
Now, my problem is the gateway sometimes jammed because it have to handle both receiving and sending sms at the same time.

I planned to use queue method(Linked List) to queue up the sms.I plan to queue the sending sms first before the gateway process the receiving sms.

I currently stuck with this.I tried using the following code:

Queue<SMSMessage> smsQueue = new LinkedList<SMSMessage>();
......
......
public void run() {
while(true) {
// peek at the head of the queue, but don't grab it
Object pull = smsQueue.peek();
SMSMessage enqueued = null;
// grab the head of the queue
if (pull!=null) {
enqueued = smsQueue.poll();
System.out.println("Enqueued successful");

//send the message here
String num = enqueued.getPhoneNo();
String msg = enqueued.getMessage();


Please help me... thanks alot..


Now exactly where is your problem.

#1.Send and receive sms at the same time ?
If so, what is the error please mention it clearly!
or
#2.With the Queue <Linked list> message system.

You can send or receive only one message at a time with a single gsm modem.

If that creates a problem and

In this case if you need to queue up the messages with a linked list,then possibly that is not the solution.

I would suggest you to use java messsage queue system.

Use connectionfactories to create connection and write your messsages there.

This would create a layer of abstraction between the message repository and the message sending classes or the modem interaction classes or what ever you call it as.


Discussion - the powerfull way to excellence!
siti aisya
Greenhorn

Joined: Aug 18, 2008
Posts: 3
So sorry for the late reply

Currently, we able to send and receive at the same time. However, during the sending and receiving sms taking place, a few sms destroyed or lost.
So, we trying to queue the sms such that we will let the sending sms to take place first. Then, the receive sms will take place.
So we plan to queue the sms.

Your suggestion for us is java messsage queue system. May i know how to implement it to our program? We using JCreatorLE 4.50 to do our java codes.

If possible, i hope sir could provide us some links for us to reference.

Thanks
 
 
subject: sms gateway(queue sms)