Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scheduled sms sending #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions misc/SMSServer/Database Scripts/MySQL.sql
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,6 @@ CREATE TABLE `smsserver_out` (
) ENGINE=MyISAM AUTO_INCREMENT=2 /*!40100 DEFAULT CHARSET=utf8*/;

/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS*/;

/* samsonbek 2014-01-13 */
ALTER TABLE smsserver_out ADD COLUMN sched_send_date DATETIME DEFAULT NULL;
2 changes: 2 additions & 0 deletions misc/SMSServer/Database Scripts/PostgreSQL.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ CREATE TABLE smsserver_out
PRIMARY KEY (id )
);

/* samsonbek 2014-01-13 */
ALTER TABLE smsserver_out ADD COLUMN sched_send_date DATETIME DEFAULT NULL;
13 changes: 9 additions & 4 deletions src/java/org/smslib/smsserver/interfaces/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,21 @@ public Collection<OutboundMessage> getMessagesToSend() throws Exception
try
{
OutboundMessage msg;
Statement cmd;
PreparedStatement cmd;
PreparedStatement pst;
ResultSet rs;
int msgCount;
msgCount = 1;
con = getDbConnection();
cmd = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
cmd = con.prepareStatement("select id, type, recipient, text, wap_url, wap_expiry_date, wap_signal, create_date, originator, encoding, status_report, flash_sms, src_port, dst_port, sent_date, ref_no, priority, status, errors, gateway_id "
+ " from " + getProperty("tables.sms_out", "smsserver_out")
+ " where status = 'U' and ( sched_send_date <= ? or sched_send_date is null ) "
+ " order by priority desc, id",
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
cmd.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
pst = con.prepareStatement("update " + getProperty("tables.sms_out", "smsserver_out") + " set status = 'Q' where id = ? ");
rs = cmd.executeQuery("select id, type, recipient, text, wap_url, wap_expiry_date, wap_signal, create_date, originator, encoding, status_report, flash_sms, src_port, dst_port, sent_date, ref_no, priority, status, errors, gateway_id from " + getProperty("tables.sms_out", "smsserver_out") + " where status = 'U' order by priority desc, id");
while (rs.next())
rs = cmd.executeQuery();
while (rs.next())
{
if (msgCount > Integer.parseInt(getProperty("batch_size"))) break;
if (getServer().checkPriorityTimeFrame(rs.getInt("priority")))
Expand Down