%docentities; ]> &adminguide;
Overview The mqueue module offers a generic message queue system in shared memory for inter-process communication using the config file. One example of usage is to send time consuming operations to one or several timer processes that consumes items in the queue, without affecting SIP message handling in the socket-listening process. There can be many defined queues. Access to queued values is done via pseudo variables.
Dependencies
&kamailio; Modules The following modules must be loaded before this module: None.
External Libraries or Applications The following libraries or applications must be installed before running &kamailio; with this module loaded: None.
Parameters
<varname>mqueue</varname> (string) Definition of a memory queue Default value is none. Value must be a list of parameters: attr=value;... The attribute 'name' is mandatory, defining the name of the queue. Optional attribute 'size' specifies the maximum number of items in queue, if it is execeeded the oldest one is removed. The parameter can be set many times, each holding the definition of one queue. Set <varname>mqueue</varname> parameter ... modparam("mqueue", "mqueue", "name=myq;size=20;") modparam("mqueue", "mqueue", "name=qaz") ...
Functions
<function moreinfo="none">mq_add(queue, key, value)</function> Add a new item (key, value) in the queue. If max size of queue is exceeded, the oldest one is removed. <function>mq_add</function> usage ... mq_add("myq", "$rU", "call from $fU"); ...
<function moreinfo="none">mq_fetch(queue)</function> Take oldest item from queue and fill $mqk(queue) and $mqv(queue) pseudo variables. Return: true on success (1); false on failure (-1) or no item fetched (-2). <function>mq_fetch</function> usage ... while(mq_fetch("myq")) { xlog("$mqk(myq) - $mqv(myq)\n"); } ...
<function moreinfo="none">mq_pv_free(queue)</function> Free the item fetched in pseudo-variables. It is optional, a new fetch frees the previous values. <function>mq_pv_free</function> usage ... mq_pv_free("myq"); ...
<function moreinfo="none">mq_size(queue)</function> Returns the current number of elements in the mqueue. If the mqueue is empty, the function returns -1. If the mqueue is not found, the function returns -2. <function>mq_size</function> usage ... $var(q_size) = mq_size("queue"); xlog("L_INFO", "Size of queue is: $var(q_size)\n"); ...
Exported Pseudo-variables $mqv(mqueue) - the most recent item key fetched from the specified mqueue $mqv(mqueue) - the most recent item value fetched from the specified mqueue $mq_size(mqueue) - the size of the specified mqueue Exported pseudo-variables are documented at &kamwikilink;.