Using res_mwi_external with realtime


I want to use res_mwi external to manually control MWI, with data in Postgres database. From the source code, I’ve gathered that the table should look something like this:

CREATE TABLE mwi_external (
    id character varying (80) NOT NULL PRIMARY KEY, -- Mailbox name
    msgs_new int NOT NULL DEFAULT 0, -- Number of new messages
    msgs_old int NOT NULL DEFAULT 0 -- Number of old messages

In extconfig.conf, I’ve put:

mwi_external => pgsql,pbx

And in sorcery.conf:


Inserted a test row:

INSERT INTO mwi_external (id, msgs_new, msgs_old) VALUES ('888@default', 2, 0);

When the device 888 subscribes to message-summary, a NOTIFY is sent with the correct number of messages. So far, so good. But, when I do:

UPDATE mwi_external set msgs_new=0 WHERE id = '888@default';

nothing happens. So it seems that res_mwi_external reads the realtime data only on startup and does not respond to changes. Which is strange, given that I see ast_sorcery_observer in source code. So I assume that I’ve missed something.

You haven’t missed anything. Sorcery doesn’t react to database changes like that, I’m also surprised this works at all since it wasn’t really written for it. The module is meant for internal API users in Asterisk, such as ARI.

Thanks for the reply, Joshua. I assumed this should work, since res_pjsip automatically detects database changes, but I guess it must use some other mechanism then. So, is there some way (from dialplan) to tell res_mwi_external to re-read the data?

I’ve realized I can use MinivmMWI application to send MWI update after updating the database. MiniVM is buggy and seems long neglected, but MinivmMWI works well enough. Somewhat kludgy solution, but it works for me.

The res_pjsip module doesn’t automatically detect database changes, instead when certain things are needing to be used (such as an endpoint) it queries at time of use instead.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.