1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
|
<?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>
This module provides asynchronous operations for handling SIP requests
in the configuration file.
</para>
<para>
Async uses t_suspend() and t_continue() from the TM and TMX modules.
</para>
<para>
Note that after invoking the asynchronous operation, the processing
will continue later in another application process. Therefore variables
stored in private memory should not be used, try to use shared memory if you
want to get values after the processing is resumed (e.g., $avp(...),
$xavp(...), $shv(...), htable $sht(...)).
</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>tm</emphasis> - transaction management.
</para>
<para>
<emphasis>tmx</emphasis> - transaction management extensions.
</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>
<title><varname>workers</varname> (int)</title>
<para>
Number of worker processes to be started to handle the asynchronous
tasks.
</para>
<para>
<emphasis>
Default value is 1.
</emphasis>
</para>
<example>
<title>Set <varname>workers</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("async", "workers", 2)
...
</programlisting>
</example>
</section>
</section>
<section>
<title>Functions</title>
<section id="async.f.async_route">
<title>
<function moreinfo="none">async_route(routename, seconds)</function>
</title>
<para>
Simulate a sleep of 'seconds' and then continue the processing of the SIP
request with the route[routename]. In case of internal errors, the
function returns false, otherwise the function exits the execution of
the script at that moment (return 0 behaviour).
</para>
<para>
The routename parameter can be a static string or a dynamic string
value with config variables.
</para>
<para>
The sleep parameter represent the number of seconds to suspend the
processing of a SIP request. Maximum value is 100. The parameter can be
a static integer or a variable holding an integer.
</para>
<para>
Since the SIP request handling is resumed in another process,
the config file execution state is practically lost. Therefore beware
that the execution of config after resume will end once the
route[routename] is finished.
</para>
<para>
This function can be used from REQUEST_ROUTE.
</para>
<example>
<title><function>async_route</function> usage</title>
<programlisting format="linespecific">
...
async_route("RESUME", "4");
...
route[RESUME] {
send_reply("404", "Not found");
exit;
}
...
</programlisting>
</example>
</section>
<section id="async.f.async_sleep">
<title>
<function moreinfo="none">async_sleep(seconds)</function>
</title>
<para>
Simulate a sleep of 'seconds' and then continue the processing of SIP
request with the next action. In case of internal errors, the function
returns false.
</para>
<para>
The sleep parameter represent the number of seconds to suspend the
processing of SIP request. Maximum value is 100. The parameter can be
a static integer or a variable holding an integer.
</para>
<para>
This function can be used from REQUEST_ROUTE.
</para>
<example>
<title><function>async_sleep</function> usage</title>
<programlisting format="linespecific">
...
async_sleep("4");
send_reply("404", "Not found");
exit;
...
</programlisting>
</example>
</section>
<section id="async.f.async_task_route">
<title>
<function moreinfo="none">async_task_route(routename)</function>
</title>
<para>
Continue the processing of the SIP request with the route[routename]
in one of the processes from core asynchronous framework. The core
parameter async_workers has to be set to enable asynchronous
framework. The task is executed as soon as a process from asynchronous
framework is idle, there is no wait time for the task like for
async_route(...).
</para>
<para>
In case of internal errors, the function returns false, otherwise the
function exits the execution of the script at that moment (return
0 behaviour).
</para>
<para>
The routename parameter can be a static string or a dynamic string
value with config variables.
</para>
<para>
Since the SIP request handling is resumed in another process,
the config file execution state is practically lost. Therefore beware
that the execution of config after resume will end once the
route[routename] is finished.
</para>
<para>
This function can be used from REQUEST_ROUTE.
</para>
<example>
<title><function>async_task_route</function> usage</title>
<programlisting format="linespecific">
...
async_task_rroute("RESUME");
...
route[RESUME] {
send_reply("404", "Not found");
exit;
}
...
</programlisting>
</example>
</section>
</section>
</chapter>
|