async_admin.xml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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 id="async.f.async_route">
  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_route</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 id="async.f.async_sleep">
  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 id="async.f.async_task_route">
  157. <title>
  158. <function moreinfo="none">async_task_route(routename)</function>
  159. </title>
  160. <para>
  161. Continue the processing of the SIP request with the route[routename]
  162. in one of the processes from core asynchronous framework. The core
  163. parameter async_workers has to be set to enable asynchronous
  164. framework. The task is executed as soon as a process from asynchronous
  165. framework is idle, there is no wait time for the task like for
  166. async_route(...).
  167. </para>
  168. <para>
  169. In case of internal errors, the function returns false, otherwise the
  170. function exits the execution of the script at that moment (return
  171. 0 behaviour).
  172. </para>
  173. <para>
  174. The routename parameter can be a static string or a dynamic string
  175. value with config variables.
  176. </para>
  177. <para>
  178. Since the SIP request handling is resumed in another process,
  179. the config file execution state is practically lost. Therefore beware
  180. that the execution of config after resume will end once the
  181. route[routename] is finished.
  182. </para>
  183. <para>
  184. This function can be used from REQUEST_ROUTE.
  185. </para>
  186. <example>
  187. <title><function>async_task_route</function> usage</title>
  188. <programlisting format="linespecific">
  189. ...
  190. async_task_route("RESUME");
  191. ...
  192. route[RESUME] {
  193. t_relay();
  194. exit;
  195. }
  196. ...
  197. </programlisting>
  198. </example>
  199. </section>
  200. </section>
  201. </chapter>