text
stringlengths
0
152
Try a few scenarios:
1. Call from an agent internally.
2. Call from a normal user to a logged-in agent.
3. Call from a normal user to an unavailable agent.
Marvel at this technological terror you’ve constructed.
Now that we’ve implemented a fairly complex feature in the dialplan, using
func_odbc to retrieve and store data in a remote relational database, you can see that
with a handful of fairly simple functions in the func_odbc.conf file and a couple of
tables in a database, you can create some powerful telephony applications.
Getting Funky with func_odbc: Hot-Desking
|
277
OK, let’s move on to the Asterisk Realtime Architecture, which has in many cases
been made obsolete by ODBC, but can still be useful.
Using Realtime
The Asterisk Realtime Architecture (ARA) allows you to store all the parameters nor‐
mally stored in your Asterisk configuration files (commonly located in /etc/asterisk)
in a database. There are two types of realtime: static and dynamic.
The static version is similar to the traditional method of reading a configuration file
(information is only loaded when triggered from the CLI), except that the data is read
from the database instead.7
The Dynamic Realtime method, which loads and updates the information as it is used
by the live system, is commonly used for things such as SIP (or IAX2, etc.) user and
peer objects, as well as voicemail boxes.
Making changes to static information requires a reload, just as if you had changed a
text file on the system, but dynamic information is polled by Asterisk as needed, so
no reload is required when changes are made to this data. Realtime is configured in
the extconfig.conf file located in the /etc/asterisk directory. This file tells Asterisk what
to load from the database and where to load it from, allowing certain files to be
loaded from the database and other files to be loaded from the standard configuration
files.
7 Yes, calling this “realtime” is somewhat misleading, as updates to the data will not affect anything happening
in real time (until a reload of the relevant module is performed).
278
|
Chapter 15: Relational Database Integration
Another (arguably older) way to store Asterisk configuration was
through an external script, which would interact with a database
and generate the appropriate flat files (or .conf files), and then
reload the appropriate module once the new file was written. There
is an advantage to this (if the database goes down, your system will
continue to function; the script will simply not update any files
until connectivity to the database is restored), but it also has disad‐
vantages. One major disadvantage is that any changes you make to
a user will not be available until you run the update script. This is
probably not a big issue on small systems, but on large systems,
waiting for changes to take effect can cause issues, such as pausing
a live call while a large file is loaded and parsed.
You can relieve some of this by utilizing a replicated database sys‐
tem. Asterisk provides the ability to fail over to another database
system. This way, you can cluster the database backend utilizing a
master-master relationship (for PostgreSQL, pgcluster, or Postgre-
R;8 for MySQL it’s native9), or a master-slave (for PostgreSQL or
Slony-I; for MySQL it’s native) replication system.
Our informal survey of such things suggests that using scripts to
write flat files from databases is not as popular as querying a data‐
base in real time (and ensuring the database has a proper amount
of fault tolerance to handle the fact that a live telecom system is
dependent on it).
Static Realtime
Static Realtime was one of the earliest ways that Asterisk configuration could be
stored in a database. It is still somewhat useful for storing simple configuration files
in a database (which you might normally place in /etc/asterisk). We don’t tend to use
it much anymore because Dynamic Realtime is far better for larger sets of data, and
the file-based configuration files are more than adequate for smaller configuration
settings.
The same rules that apply to flat files on your system still apply when you’re using
Static Realtime. For example, after making changes to the configuration you still have
to run the module reload command for the relevant technology (e.g., *CLI> module
reload res_musiconhold.so).
8 pgcluster appears to be a dead project, and Postgres-R appears to be in its infancy, so there may currently be
no good solution for master-master replication using PostgreSQL.
9 There are several tutorials on the web describing how to set up replication with MySQL.