Table of Contents
List of Examples
workers
parameterasync_route
usageasync_sleep
usageasync_workers
usageasync_task_route
usageTable of Contents
This module provides asynchronous operations for handling SIP requests in the configuration file.
Async uses t_suspend() and t_continue() from the TM and TMX modules.
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(...)).
The following modules must be loaded before this module:
tm - transaction management.
tmx - transaction management extensions.
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).
The routename parameter can be a static string or a dynamic string value with config variables.
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.
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.
This function can be used from REQUEST_ROUTE.
Example 1.2. async_route
usage
... async_route("RESUME", "4"); ... route[RESUME] { send_reply("404", "Not found"); exit; } ...
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.
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.
This function can be used from REQUEST_ROUTE.
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(...).
To enable the core asynchronous framework, you need to set the async_workers core parameter in the configuration file. See the core cookbook for more information.
Example 1.4. async_workers
usage
... ; Enable 8 worker processes used by async and other modules async_workers=8 ...
In case of internal errors, the function returns false, otherwise the function exits the execution of the script at that moment (return 0 behaviour).
The routename parameter can be a static string or a dynamic string value with config variables.
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.
This function can be used from REQUEST_ROUTE.
Example 1.5. async_task_route
usage
... async_task_route("RESUME"); ... route[RESUME] { t_relay(); exit; } ...