mqueue_admin.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <?xml version="1.0" encoding='ISO-8859-1'?>
  2. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  4. <!-- Include general documentation entities -->
  5. <!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
  6. %docentities;
  7. ]>
  8. <!-- Module User's Guide -->
  9. <chapter>
  10. <title>&adminguide;</title>
  11. <section>
  12. <title>Overview</title>
  13. <para>
  14. The mqueue module offers a generic message queue system in shared memory for
  15. inter-process communication using the config file. One example of usage is
  16. to send time consuming operations to one or several timer processes that consumes
  17. items in the queue, without affecting SIP message handling in the socket-listening
  18. process.
  19. </para>
  20. <para>
  21. There can be many defined queues. Access to queued values is done via
  22. pseudo variables.
  23. </para>
  24. </section>
  25. <section>
  26. <title>Dependencies</title>
  27. <section>
  28. <title>&kamailio; Modules</title>
  29. <para>
  30. The following modules must be loaded before this module:
  31. <itemizedlist>
  32. <listitem>
  33. <para>
  34. <emphasis>None</emphasis>.
  35. </para>
  36. </listitem>
  37. </itemizedlist>
  38. </para>
  39. </section>
  40. <section>
  41. <title>External Libraries or Applications</title>
  42. <para>
  43. The following libraries or applications must be installed before running
  44. &kamailio; with this module loaded:
  45. <itemizedlist>
  46. <listitem>
  47. <para>
  48. <emphasis>None</emphasis>.
  49. </para>
  50. </listitem>
  51. </itemizedlist>
  52. </para>
  53. </section>
  54. </section>
  55. <section>
  56. <title>Parameters</title>
  57. <section id="mqueue.p.mqueue">
  58. <title><varname>mqueue</varname> (string)</title>
  59. <para>
  60. Definition of a memory queue
  61. </para>
  62. <para>
  63. <emphasis>
  64. Default value is <quote>none</quote>.
  65. </emphasis>
  66. </para>
  67. <para>
  68. Value must be a list of parameters: attr=value;... The attribute 'name'
  69. is mandatory, defining the name of the queue. Optional attribute 'size'
  70. specifies the maximum number of items in queue, if it is execeeded the
  71. oldest one is removed.
  72. </para>
  73. <para>
  74. The parameter can be set many times, each holding the definition of one
  75. queue.
  76. </para>
  77. <example>
  78. <title>Set <varname>mqueue</varname> parameter</title>
  79. <programlisting format="linespecific">
  80. ...
  81. modparam("mqueue", "mqueue", "name=myq;size=20;")
  82. modparam("mqueue", "mqueue", "name=qaz")
  83. ...
  84. </programlisting>
  85. </example>
  86. </section>
  87. </section>
  88. <section>
  89. <title>Functions</title>
  90. <section id="mqueue.f.mq_add">
  91. <title>
  92. <function moreinfo="none">mq_add(queue, key, value)</function>
  93. </title>
  94. <para>
  95. Add a new item (key, value) in the queue. If max size of queue is
  96. exceeded, the oldest one is removed.
  97. </para>
  98. <example>
  99. <title><function>mq_add</function> usage</title>
  100. <programlisting format="linespecific">
  101. ...
  102. mq_add("myq", "$rU", "call from $fU");
  103. ...
  104. </programlisting>
  105. </example>
  106. </section>
  107. <section id="mqueue.f.mq_fetch">
  108. <title>
  109. <function moreinfo="none">mq_fetch(queue)</function>
  110. </title>
  111. <para>
  112. Take oldest item from queue and fill $mqk(queue) and
  113. $mqv(queue) pseudo variables.
  114. </para>
  115. <para>
  116. Return: true on success (1); false on failure (-1) or
  117. no item fetched (-2).
  118. </para>
  119. <example>
  120. <title><function>mq_fetch</function> usage</title>
  121. <programlisting format="linespecific">
  122. ...
  123. while(mq_fetch("myq"))
  124. {
  125. xlog("$mqk(myq) - $mqv(myq)\n");
  126. }
  127. ...
  128. </programlisting>
  129. </example>
  130. </section>
  131. <section id="mqueue.f.mq_pv_free">
  132. <title>
  133. <function moreinfo="none">mq_pv_free(queue)</function>
  134. </title>
  135. <para>
  136. Free the item fetched in pseudo-variables. It is optional, a new fetch
  137. frees the previous values.
  138. </para>
  139. <example>
  140. <title><function>mq_pv_free</function> usage</title>
  141. <programlisting format="linespecific">
  142. ...
  143. mq_pv_free("myq");
  144. ...
  145. </programlisting>
  146. </example>
  147. </section>
  148. <section id="mqueue.f.mq_size">
  149. <title>
  150. <function moreinfo="none">mq_size(queue)</function>
  151. </title>
  152. <para>
  153. Returns the current number of elements in the mqueue.
  154. </para>
  155. <para>
  156. If the mqueue is empty, the function returns -1. If the
  157. mqueue is not found, the function returns -2.
  158. </para>
  159. <example>
  160. <title><function>mq_size</function> usage</title>
  161. <programlisting format="linespecific">
  162. ...
  163. $var(q_size) = mq_size("queue");
  164. xlog("L_INFO", "Size of queue is: $var(q_size)\n");
  165. ...
  166. </programlisting>
  167. </example>
  168. </section>
  169. </section>
  170. <section>
  171. <title>Exported Pseudo-variables</title>
  172. <itemizedlist>
  173. <listitem>
  174. <emphasis>$mqv(mqueue)</emphasis> - the most recent item key fetched from the specified mqueue
  175. </listitem>
  176. <listitem>
  177. <emphasis>$mqv(mqueue)</emphasis> - the most recent item value fetched from the specified mqueue
  178. </listitem>
  179. <listitem>
  180. <emphasis>$mq_size(mqueue)</emphasis> - the size of the specified mqueue
  181. </listitem>
  182. </itemizedlist>
  183. <para>
  184. Exported pseudo-variables are documented at &kamwikilink;.
  185. </para>
  186. </section>
  187. </chapter>