Could you please rephrase / detail your question, as I do not understand
what you are asking.
Thanks,
Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com
On 01/24/2017 03:44 PM, Ahmed Munir wrote:
Thanks, have been working on this and it is working.
Btw, I would like to know, is there a way to resume route while using
async avp_db_query? As currently setting/declaring another async route
for DB query, looking for resume route in main routing script.
On Tue, Jan 24, 2017 at 6:45 AM, Bogdan-Andrei Iancu
<[email protected] <mailto:[email protected]>> wrote:
Hi Ahmed,
Note the $rc holds the return code of the LAST executed
statement/instruction/function in the script. In the first case
you do it right by saving the ret code of the avp_db_query into a
separate variable, so you can use it even later.
In the sync script, the $rc, when entering the resume route, it
will hold the return code of the avp_db_query() function. But the
$rc will be changed when doing the xlog(), the if(), etc...So when
you do the last xlog(), the $rc will have nothing to do with the
avp_db_query(). If you need it later in the script, better save
it, as you do in the first example.
Regards,
Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com <http://www.opensips-solutions.com>
On 01/20/2017 01:31 AM, Ahmed Munir wrote:
Hi,
Currently I'm trying to use async fucntion for avp_db_query. The
issue I'm facing while using it as not retrieving or returning
correct return code and not execute later part of the routing
script. See old & new DB queries;
Without Async: ---------------------- route[1]{ ...
if($var(Outpluseflag) == 0) { avp_db_query("SELECT
Outpulse_number,setid FROM Prefix_data where Program_prefix =
'$var(pg_prefix)'", "$avp(outpluse), $avp(trunkid)");
$var(res) = $retcode; # or you can just use
$retcode! xlog("--------- OB Route 1-1 DB fetched
value outpluse -> $avp(outpluse) | trunkid -> $avp(trunkid) |
Return Code: $rc | Var Res: $var(res)-------");
if ($var(res) > 0) {
cache_store("local", "DID_$tU", "$avp(outpluse)", 60);
cache_store("local", "Trunk_$tU",
"$avp(trunkid)", 60); } #xlog("DB
fetched value outpluse -> $avp(outpluse) | trunkid ->
$avp(trunkid) | Return Code -> $var(res)");
xlog("--------- OB Route 1-2 DB fetched value outpluse ->
$avp(outpluse) | trunkid -> $avp(trunkid) | Return Code: $rc |
Var Res: $var(res)-------"); }
} With Async: -------------------
route[1]{
...
if($var(Outpluseflag) == 0) { async(avp_db_query("SELECT
Outpulse_number,setid FROM Prefix_data where Program_prefix =
'$var(pg_prefix)'", "$avp(outpluse), $avp(trunkid)"),ob_route_1);
} }
route[ob_route_1]{ xlog("--------- OB Route 1-1 DB
fetched value outpluse -> $avp(outpluse) | trunkid ->
$avp(trunkid) | Return Code: $rc-------"); if ($rc > 0) {
cache_store("local", "DID_$tU", "$avp(outpluse)",
60); cache_store("local", "Trunk_$tU",
"$avp(trunkid)", 60); } xlog("--------- OB Route
1-2 DB fetched value outpluse -> $avp(outpluse) | trunkid ->
$avp(trunkid) | Return Code: $rc-------"); }
The records in xlog I'm getting without using async; Jan 19
18:05:39 qorblpsisprxyd1 /usr/sbin/opensips[14040]: --------- OB
Route 1-1 DB fetched value outpluse -> 6099020000
<tel:%28609%29%20902-0000> | trunkid -> 117 | Return Code: 1 |
Var Res: 1------- Jan 19 18:05:39 qorblpsisprxyd1
/usr/sbin/opensips[14040]: --------- OB Route 1-2 DB fetched
value outpluse -> 6099020000 <tel:%28609%29%20902-0000> | trunkid
-> 117 | Return Code: 1 | Var Res: 1-------
Whereas, records in xlog I'm getting using async; Jan 19 18:10:07
qorblpsisprxyd1 /usr/sbin/opensips[14109]: --------- OB Route 1-1
DB fetched value outpluse -> 6099020000
<tel:%28609%29%20902-0000> | trunkid -> 117 | Return Code:
1------- Jan 19 18:10:07 qorblpsisprxyd1
/usr/sbin/opensips[14109]: --------- OB Route 1-2 DB fetched
value outpluse -> 6099020000 <tel:%28609%29%20902-0000> | trunkid
-> 117 | Return Code: 0-------
Is there is way to properly retain the $retcode/$rc in version
2.2.2? Seems like using async return code(s) are not properly set
or the avp variables are not setting up correct using async
statement.
Please advise, if the above async db statement is correct as
shared in sample above.
--
Regards, Ahmed Munir Chohan
_______________________________________________
Users mailing list
[email protected] <mailto:[email protected]>
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
<http://lists.opensips.org/cgi-bin/mailman/listinfo/users>
--
Regards, Ahmed Munir Chohan
_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users