async_admin.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. This module provides asynchronous operations for handling SIP requests
  15. in the configuration file.
  16. </para>
  17. <para>
  18. Async uses t_suspend() and t_continue() from the TM and TMX modules.
  19. </para>
  20. <para>
  21. Note that after invoking the asynchronous operation, the processing
  22. will continue later in another application process. Therefore variables
  23. stored in private memory should not be used, try to use shared memory if you
  24. want to get values after the processing is resumed (e.g., $avp(...),
  25. $xavp(...), $shv(...), htable $sht(...)).
  26. </para>
  27. </section>
  28. <section>
  29. <title>Dependencies</title>
  30. <section>
  31. <title>&kamailio; Modules</title>
  32. <para>
  33. The following modules must be loaded before this module:
  34. <itemizedlist>
  35. <listitem>
  36. <para>
  37. <emphasis>tm</emphasis> - transaction management.
  38. </para>
  39. <para>
  40. <emphasis>tmx</emphasis> - transaction management extensions.
  41. </para>
  42. </listitem>
  43. </itemizedlist>
  44. </para>
  45. </section>
  46. <section>
  47. <title>External Libraries or Applications</title>
  48. <para>
  49. The following libraries or applications must be installed before running
  50. &kamailio; with this module loaded:
  51. <itemizedlist>
  52. <listitem>
  53. <para>
  54. <emphasis>None</emphasis>
  55. </para>
  56. </listitem>
  57. </itemizedlist>
  58. </para>
  59. </section>
  60. </section>
  61. <section>
  62. <title>Parameters</title>
  63. <section>
  64. <title><varname>workers</varname> (int)</title>
  65. <para>
  66. Number of worker processes to be started to handle the asynchronous
  67. tasks.
  68. </para>
  69. <para>
  70. <emphasis>
  71. Default value is 1.
  72. </emphasis>
  73. </para>
  74. <example>
  75. <title>Set <varname>workers</varname> parameter</title>
  76. <programlisting format="linespecific">
  77. ...
  78. modparam("async", "workers", 2)
  79. ...
  80. </programlisting>
  81. </example>
  82. </section>
  83. </section>
  84. <section>
  85. <title>Functions</title>
  86. <section>
  87. <title>
  88. <function moreinfo="none">async_route(routename, seconds)</function>
  89. </title>
  90. <para>
  91. Simulate a sleep of 'seconds' and then continue the processing of the SIP
  92. request with the route[routename]. In case of internal errors, the
  93. function returns false, otherwise the function exits the execution of
  94. the script at that moment (return 0 behaviour).
  95. </para>
  96. <para>
  97. The routename parameter can be a static string or a dynamic string
  98. value with config variables.
  99. </para>
  100. <para>
  101. The sleep parameter represent the number of seconds to suspend the
  102. processing of a SIP request. Maximum value is 100. The parameter can be
  103. a static integer or a variable holding an integer.
  104. </para>
  105. <para>
  106. Since the SIP request handling is resumed in another process,
  107. the config file execution state is practically lost. Therefore beware
  108. that the execution of config after resume will end once the
  109. route[routename] is finished.
  110. </para>
  111. <para>
  112. This function can be used from REQUEST_ROUTE.
  113. </para>
  114. <example>
  115. <title><function>async_sleep</function> usage</title>
  116. <programlisting format="linespecific">
  117. ...
  118. async_route("RESUME", "4");
  119. ...
  120. route[RESUME] {
  121. send_reply("404", "Not found");
  122. exit;
  123. }
  124. ...
  125. </programlisting>
  126. </example>
  127. </section>
  128. <section>
  129. <title>
  130. <function moreinfo="none">async_sleep(seconds)</function>
  131. </title>
  132. <para>
  133. Simulate a sleep of 'seconds' and then continue the processing of SIP
  134. request with the next action. In case of internal errors, the function
  135. returns false.
  136. </para>
  137. <para>
  138. The sleep parameter represent the number of seconds to suspend the
  139. processing of SIP request. Maximum value is 100. The parameter can be
  140. a static integer or a variable holding an integer.
  141. </para>
  142. <para>
  143. This function can be used from REQUEST_ROUTE.
  144. </para>
  145. <example>
  146. <title><function>async_sleep</function> usage</title>
  147. <programlisting format="linespecific">
  148. ...
  149. async_sleep("4");
  150. send_reply("404", "Not found");
  151. exit;
  152. ...
  153. </programlisting>
  154. </example>
  155. </section>
  156. </section>
  157. </chapter>