123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <?xml version="1.0" encoding='ISO-8859-1'?>
- <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
- "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
- <!-- Include general documentation entities -->
- <!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
- %docentities;
- ]>
- <!-- Module User's Guide -->
- <chapter>
-
- <title>&adminguide;</title>
-
- <section>
- <title>Overview</title>
- <para>
- 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.
- </para>
- <para>
- There can be many defined queues. Access to queued values is done via
- pseudo variables.
- </para>
- </section>
- <section>
- <title>Dependencies</title>
- <section>
- <title>&kamailio; Modules</title>
- <para>
- The following modules must be loaded before this module:
- <itemizedlist>
- <listitem>
- <para>
- <emphasis>None</emphasis>.
- </para>
- </listitem>
- </itemizedlist>
- </para>
- </section>
- <section>
- <title>External Libraries or Applications</title>
- <para>
- The following libraries or applications must be installed before running
- &kamailio; with this module loaded:
- <itemizedlist>
- <listitem>
- <para>
- <emphasis>None</emphasis>.
- </para>
- </listitem>
- </itemizedlist>
- </para>
- </section>
- </section>
- <section>
- <title>Parameters</title>
- <section id="mqueue.p.mqueue">
- <title><varname>mqueue</varname> (string)</title>
- <para>
- Definition of a memory queue
- </para>
- <para>
- <emphasis>
- Default value is <quote>none</quote>.
- </emphasis>
- </para>
- <para>
- 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.
- </para>
- <para>
- The parameter can be set many times, each holding the definition of one
- queue.
- </para>
- <example>
- <title>Set <varname>mqueue</varname> parameter</title>
- <programlisting format="linespecific">
- ...
- modparam("mqueue", "mqueue", "name=myq;size=20;")
- modparam("mqueue", "mqueue", "name=qaz")
- ...
- </programlisting>
- </example>
- </section>
- </section>
-
- <section>
- <title>Functions</title>
- <section id="mqueue.f.mq_add">
- <title>
- <function moreinfo="none">mq_add(queue, key, value)</function>
- </title>
- <para>
- Add a new item (key, value) in the queue. If max size of queue is
- exceeded, the oldest one is removed.
- </para>
- <example>
- <title><function>mq_add</function> usage</title>
- <programlisting format="linespecific">
- ...
- mq_add("myq", "$rU", "call from $fU");
- ...
- </programlisting>
- </example>
- </section>
-
- <section id="mqueue.f.mq_fetch">
- <title>
- <function moreinfo="none">mq_fetch(queue)</function>
- </title>
- <para>
- Take oldest item from queue and fill $mqk(queue) and
- $mqv(queue) pseudo variables.
- </para>
- <para>
- Return: true on success (1); false on failure (-1) or
- no item fetched (-2).
- </para>
- <example>
- <title><function>mq_fetch</function> usage</title>
- <programlisting format="linespecific">
- ...
- while(mq_fetch("myq"))
- {
- xlog("$mqk(myq) - $mqv(myq)\n");
- }
- ...
- </programlisting>
- </example>
- </section>
-
- <section id="mqueue.f.mq_pv_free">
- <title>
- <function moreinfo="none">mq_pv_free(queue)</function>
- </title>
- <para>
- Free the item fetched in pseudo-variables. It is optional, a new fetch
- frees the previous values.
- </para>
- <example>
- <title><function>mq_pv_free</function> usage</title>
- <programlisting format="linespecific">
- ...
- mq_pv_free("myq");
- ...
- </programlisting>
- </example>
- </section>
- <section id="mqueue.f.mq_size">
- <title>
- <function moreinfo="none">mq_size(queue)</function>
- </title>
- <para>
- Returns the current number of elements in the mqueue.
- </para>
- <para>
- If the mqueue is empty, the function returns -1. If the
- mqueue is not found, the function returns -2.
- </para>
- <example>
- <title><function>mq_size</function> usage</title>
- <programlisting format="linespecific">
- ...
- $var(q_size) = mq_size("queue");
- xlog("L_INFO", "Size of queue is: $var(q_size)\n");
- ...
- </programlisting>
- </example>
- </section>
-
- </section>
- <section>
- <title>Exported Pseudo-variables</title>
- <itemizedlist>
- <listitem>
- <emphasis>$mqv(mqueue)</emphasis> - the most recent item key fetched from the specified mqueue
- </listitem>
- <listitem>
- <emphasis>$mqv(mqueue)</emphasis> - the most recent item value fetched from the specified mqueue
- </listitem>
- <listitem>
- <emphasis>$mq_size(mqueue)</emphasis> - the size of the specified mqueue
- </listitem>
- </itemizedlist>
- <para>
- Exported pseudo-variables are documented at &kamwikilink;.
- </para>
- </section>
- </chapter>
|