Rails Kitchen

It's a place to write on stuff I learned recently.

Installing and Configuring SQL-Based Queue Engine for Kannel (SQL Box)

| Comments

SQL box is a special Kannel box that sits between bearer box and SMS box and uses a database queue to store and forward messages. Messages are queued on a configurable table (defaults to send_sms) and moved to another table (defaults to sent_sms) afterwards.
After installing gateway, we need to compile SQL box.
Steps:

  1 - cd to directory where Kannel is unzipped and then type the following commands
1
2
3
4
cd addons/sqlbox/
sudo ./bootstrap
sudo ./configure --with-kannel-dir=/usr/local/kannel-1.5.0/
sudo make bindir=/usr/local/kannel/kannel-1.5.0/
2 -Create a file named smsbox.conf and the following configuration
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#SQL BOX CONFIG

group = sqlbox
id = sqlbox-db
smsbox-id = sqlbox
global-sender = ""
bearerbox-host = localhost
bearerbox-port = 13010
smsbox-port = 13020
smsbox-port-ssl = false
sql-log-table = sent_sms
sql-insert-table = send_sms
log-file = "/var/log/kannel/kannel-sqlbox.log"

# Database connection examples. Please uncomment as needed
# Example MYSQL Connection

group = mysql-connection
id = sqlbox-db
host = localhost
username = username
password = password
database = kannel_db
3 - create  send_sms table using following sql command
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
CREATE TABLE `send_sms` (
                          `sql_id` bigint(20) NOT NULL auto_increment,
                          `momt` enum('MO','MT') default NULL,
                          `sender` varchar(20) default NULL,
                          `receiver` varchar(20) default NULL,
                          `udhdata` blob,<br />  `msgdata` text,
                          `time` bigint(20) default NULL,
                          `smsc_id` varchar(255) default NULL,
                          `service` varchar(255) default NULL,
                          `account` varchar(255) default NULL,
                          `id` bigint(20) default NULL,
                          `sms_type` bigint(20) default NULL,
                          `mclass` bigint(20) default NULL,
                          `mwi` bigint(20) default NULL,
                          `coding` bigint(20) default NULL,
                          `compress` bigint(20) default NULL,
                          `validity` bigint(20) default NULL,
                          `deferred` bigint(20) default NULL,
                          `dlr_mask` bigint(20) default NULL,
                          `dlr_url` varchar(255) default NULL,
                          `pid` bigint(20) default NULL,
                          `alt_dcs` bigint(20) default NULL,
                          `rpi` bigint(20) default NULL,
                          `charset` varchar(255) default NULL,
                          `boxc_id` varchar(255) default NULL,
                          `meta_data` varchar(255) default NULL,
                          `foreign_id` bigint(20) default NULL,
                          `binfo` varchar(255) default NULL,
                          PRIMARY KEY (`sql_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;
4 - Create  sent_sms table using same structure with changing table name
Now start bearerbox and sqlbox using commands
1
2
sudo /usr/local/kannel-1.5.0/sbin bearerbox /home/shaiju/kannel/kannel.conf
sudo /usr/local/kannel-1.5.0/sbin sqlbox /home/shaiju/kannel/sqlbox.conf
Example
As when you’re using the sendsms interface, you don’t need to specify all the columns in order to succesfully enqueue a message.
Here’s an example query you can use to send a simple message using Sqlbox:
1
INSERT INTO send_sms (  momt, sender, receiver, msgdata, sms_type, smsc_id) VALUES (  'MT', 'TESTID', '9995323922', 'Hello world', 2,'testsmsc1');
The former example would send a message with text “Hello world” to number “9995323922”. If possible, the sender would be set to “TESTID”.You can add other parameters to specify routing, charset encoding and any other settings your setup may require
If you are keen to learn more about this , Refer Here

Comments