Summary:ASTERISK-07900: [branch] RT Storage for voicemail - initial release
Reporter:Sergey Tamkovich (sergee)Labels:
Date Opened:2006-10-09 04:02:12Date Closed:2008-10-21 10:03:58
Versions:Frequency of
Environment:Attachments:( 0) rt-voicemail-r44556.diff
( 1) rt-voicemail-r59804.diff
( 2) rt-voicemail-r60067.diff
( 3) rt-voicemail-r60117.diff
Description:This is an initial release of RT Storage for voicemail. Right now it works simultaneously with "traditional storage" and stores only "extended data" to RT database.

To enable it, you should apply this patch, compile and install asterisk, and add an entry to extconfig.conf:

voicemail_data => mysql,dbname,voicemail_data

That's all. I hope this patch will get in trunk, meanwhile i'll try to improve it. Here is my short TODO list:

1) Add new entry to voicemail.conf, which will switch between "traditional" and realtime storage.
2) Implement storage of voicemail message itself in RT database.
3) Add new entry to voicemail.conf which will allow you to chose what do you want to store in RT DB (extended data only or extended data + messages)

I think it is better to use RT engine in your modules, and not to use any DB drivers directly.
Hope you'll like idea of this patch.

PS: This patch requires my previous patch (RT API extension) : ASTERISK-7899


// Disclaimer was sent by fax at 5th october 2006.
Table structure for mysql:

CREATE TABLE `voicemail_data` (
`id` int(10) unsigned NOT NULL auto_increment,
`filename` varchar(80) NOT NULL default '',
`origmailbox` varchar(80) NOT NULL default '',
`context` varchar(80) NOT NULL default '',
`macrocontext` varchar(80) NOT NULL default '',
`exten` varchar(80) NOT NULL default '',
`priority` int(11) NOT NULL default '0',
`callerchan` varchar(80) NOT NULL default '',
`callerid` varchar(80) NOT NULL default '',
`origdate` varchar(32) NOT NULL default '',
`origtime` bigint(20) unsigned NOT NULL default '0',
`category` varchar(80) NOT NULL default '',
`duration` int(10) unsigned NOT NULL default '0',
Comments:By: Olle Johansson (oej) 2006-10-29 14:32:58.000-0600

Hybrid realtime mode... Interesting.

By: Sergey Tamkovich (sergee) 2006-10-29 15:16:44.000-0600

any ideas? suggestions?
What should i do to get this patch into trunk? :)

By: Jason Parker (jparker) 2006-10-29 15:18:09.000-0600

Get people to test it. :)

By: jmls (jmls) 2006-11-19 13:26:05.000-0600

sergee: did you get anyone to test this ? perhaps if you asked on -dev and -user mailing list people may come forward.

By: jmls (jmls) 2007-02-11 03:22:41.000-0600

sergee: ping ..

By: Sergey Tamkovich (sergee) 2007-03-05 06:09:46.000-0600

jmls, sorry for delay, was out for a while.
As for testing - no, i didn't get anyone to test it except flot, he post his comment at 8118 instead of here. As for me, i'm already using this piece of code at 6 sites, no problems found.

there are 5 people monitoring this issue, maybe someone would like to test it and write a review here?

I'm cleaning up 8118 right now.

By: Steve Murphy (murf) 2007-03-27 12:41:33


The first hunk in the patch shows this:

+ if(ast_check_realtime("voicemail_data")) {
+ char tmpid[16];
+ snprintf(tmpid, sizeof(tmpid), "%d", rtmsgid);
+ ast_destroy_realtime("voicemail_data", "filename", fn, NULL);
+ }

It's embedded in the middle of the remove_file function. It's referring to rtmsgid, which is not defined, and not using the tmpid once it's been filled in!  This seems an error; please check your code and let me know if you can update this.

By: Sergey Tamkovich (sergee) 2007-03-27 13:17:32

Murf, thank you very much for commiting 8118! Give me 1 week and i will clean up this code.

By: Sergey Tamkovich (sergee) 2007-04-03 06:16:02

Murf, i cleaned up a code, also i updated it to eork properly with current trunk. Thank you for your patience :)

Brief reminder: This patch enables "Hybrid Voicemail" ((c) oej) if you have "voicemail_data" entry in your extconfig.conf - all data about voicemail messages will be duplicated to realtime storage.

By: Sergey Tamkovich (sergee) 2007-04-03 08:00:28

voicemail changed a little bit for last 6 month and my patch doesn't work with current svn-trunk properly, need to spend a little bit more time on it...

By: Sergey Tamkovich (sergee) 2007-04-04 07:56:52

rt-voicemail-r60067.diff - fixed version uploaded. Works good with current trunk. Code cleaned up and indented according to CODING-GUIDELINES.

By: Sergey Tamkovich (sergee) 2007-04-04 08:07:05

if you have error like "undefined symbol ast_store_realtime()" - then you need to apply last patch from bug # 8118:


By: Steve Murphy (murf) 2007-04-11 09:10:06

The latest patch applied to trunk via  61378.

By: Tilghman Lesher (tilghman) 2008-10-08 16:38:29

I am reopening this feature, because it doesn't actually work.  The primary problem is that this code assumes that the STORE method of realtime returns a record ID, which it does NOT.  The STORE method instead returns a count of how many rows were affected by the query (either 1 or 0).

By: Tilghman Lesher (tilghman) 2008-10-08 17:13:47

I have fixed this in my own branch, team/tilghman/realtime_update2, with a corresponding branch in asterisk-addons.

By: Sergey Tamkovich (sergee) 2008-10-21 06:48:30

Corydon76, this issue doesn't implement STORE method, you should reopen 8118 instead of this one.

BTW, it works fine as of rev 61378 (maybe it was damaged later in SVN?)

+int ast_store_realtime(const char *family, ...) {
+ struct ast_config_engine *eng;
+ int res = -1;
+ char db[256]="";
+ char table[256]="";
+ va_list ap;
+ va_start(ap, family);
+ eng = find_engine(family, db, sizeof(db), table, sizeof(table));
+ if (eng && eng->store_func)
+ res = eng->store_func(db, table, ap);
+ va_end(ap);
+ return res;

+static int store_mysql(const char *database, const char *table, va_list ap) {
+ insertid = mysql_insert_id(&mysql);
+ return (int)insertid;

everything works fine in revision 61378

By: Tilghman Lesher (tilghman) 2008-10-21 10:03:04

sergee: try using a driver that doesn't implement getting the insert id, such as ODBC, LDAP, SQLite, etc.

By: Tilghman Lesher (tilghman) 2008-10-21 10:03:55

Branch has been merged, so I'm reclosing this issue.