Whether you want to do an http query, send an email, write to a storage system for a specific SIP event, that uses the time and resources of your SIP routing engine and you cannot afford blocking all application processes that handle SIP traffic.
There are a lot of reason you would like to do such operations, for example:
- monitoring activity - notify when the rate of incoming SIP requests exceed a threshold - alert on flood
- real time notifications to twitter, facebook or classic email for events such as missed calls or a particular user becomes online
- logging purposes - write details about various situations to a storage system
For example, a typical usage is to start dedicated processes to consume messages from the queues. You can do that in configu using rtimer module - start separate processes that execute periodically a route block from config, where you process messages from queues.
Next is an example of usage:
- the sip worker process writes in queue "alert" when pike modules triggers alert due to high traffic rate from same IP
- process checks every 5 seconds checks if there are message in queue 'alert' and writes to syslog all the messages in the queue
modparam("rtimer", "timer", "name=ta;interval=5;mode=1;")Here you find the online documentation for mqueue module:
modparam("rtimer", "exec", "timer=ta;route=QMALERT")
modparam("mqueue", "mqueue", "name=alert")
mq_add("alert", "$si:$sp", "pike flood detected [$rm] $fu => $ru");
xlog("L_ALERT","ALERT: src [$mqk(alert)] - $mqv(alert)\n");