async(wait_for_event()) statement in a branch_route[]

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

async(wait_for_event()) statement in a branch_route[]

Vitalii Aleksandrov
Hi,

I'm a bit new to opensips, while have some experience with kamailio.

Trying to figure out whether it's possible to use async() statement from
branch_route[].

 From the documentation I understood that async() functionality is
tightly connected to the TM module and creates some context attached to
a transaction, suspends it and resumes a transaction on an event. If
said above is correct I suppose calling async() from a branch_route[] to
suspend only one branch and expect that other branches will continue
their normal execution is not what it was designed for..

Is there any way to forward a branch while other branches wait for an
async event or i/o?

Would appreciate any ideas.


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: async(wait_for_event()) statement in a branch_route[]

Bogdan-Andrei Iancu-2
Hi Vitalii,

The async() statement can be used only in REQUEST route. Still, whatever
you need to do in terms of async query from branch route can also be
done from request route.

Regards,

Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
   http://www.opensips-solutions.com
OpenSIPS Bootcamp 2018
   http://opensips.org/training/OpenSIPS_Bootcamp_2018/

On 11/01/2018 01:46 PM, Vitalii Aleksandrov wrote:

> Hi,
>
> I'm a bit new to opensips, while have some experience with kamailio.
>
> Trying to figure out whether it's possible to use async() statement
> from branch_route[].
>
> From the documentation I understood that async() functionality is
> tightly connected to the TM module and creates some context attached
> to a transaction, suspends it and resumes a transaction on an event.
> If said above is correct I suppose calling async() from a
> branch_route[] to suspend only one branch and expect that other
> branches will continue their normal execution is not what it was
> designed for..
>
> Is there any way to forward a branch while other branches wait for an
> async event or i/o?
>
> Would appreciate any ideas.
>
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: async(wait_for_event()) statement in a branch_route[]

Vitalii Aleksandrov
Hi Bogdan,

Ok. Let's say I have 5 branches and before calling t_relay() want to
iterate over branches and do some async() action. From my understanding
if I do something via async() it will suspend the whole transaction with
all branches and if I need the same action for every branch it will
create a big PDD because all async() calls will be done sequentially.

As a workaround I think I can send all branches to myself (spiral call)
and receiving those INVITEs from loopback opensips will create a
separate transaction for every destination so I'll be able to run
async() tasks in parallel and forward a call to every destination
immediately its async() task is finished.


> Hi Vitalii,
>
> The async() statement can be used only in REQUEST route. Still,
> whatever you need to do in terms of async query from branch route can
> also be done from request route.
>
> Regards,
>
> Bogdan-Andrei Iancu
>
> OpenSIPS Founder and Developer
>   http://www.opensips-solutions.com
> OpenSIPS Bootcamp 2018
>   http://opensips.org/training/OpenSIPS_Bootcamp_2018/
>
> On 11/01/2018 01:46 PM, Vitalii Aleksandrov wrote:
>> Hi,
>>
>> I'm a bit new to opensips, while have some experience with kamailio.
>>
>> Trying to figure out whether it's possible to use async() statement
>> from branch_route[].
>>
>> From the documentation I understood that async() functionality is
>> tightly connected to the TM module and creates some context attached
>> to a transaction, suspends it and resumes a transaction on an event.
>> If said above is correct I suppose calling async() from a
>> branch_route[] to suspend only one branch and expect that other
>> branches will continue their normal execution is not what it was
>> designed for..
>>
>> Is there any way to forward a branch while other branches wait for an
>> async event or i/o?
>>
>> Would appreciate any ideas.
>>
>>
>> _______________________________________________
>> Users mailing list
>> [hidden email]
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: async(wait_for_event()) statement in a branch_route[]

SamyGo
Hi Bogdan,
Intrigued by this thread, I recall in older threads I was told that I can do something like this, I'm going to use my example.

event_route[ABCD]{
          route(DO_SOMETHING);
}
and then in that DO_SOMETHING route I can use the redis/mysql functions or anything that is not acceptable to be used in the event_route.

By the same analogy is this also the right way to write?

branch_route[per_branch_ops]{
                xlog("I'm a branch of the call , I cant do alot here");
                route(WAIT_FOR_EVENT);
}

where;

route[WAIT_FOR_EVENT]{
       async(wait_for_event("ABCX","$avp(filter"),"40"),"resume_here");
}

I think another way to ask Vitalii's question would be, how parallel is "parallel forking".?  If there are 5 branches and each of them takes between A-Z amount of time to process script functions then all of them are going to be relayed out only when ALL branches are done processing? or each branch is relayed out independent of how much time other branch is taking. 

Hope to catch some insight on this. (in context of opensips version 2.4.2)

Regards,
Sammy

On Fri, Nov 2, 2018 at 6:07 AM Vitalii Aleksandrov <[hidden email]> wrote:
Hi Bogdan,

Ok. Let's say I have 5 branches and before calling t_relay() want to
iterate over branches and do some async() action. From my understanding
if I do something via async() it will suspend the whole transaction with
all branches and if I need the same action for every branch it will
create a big PDD because all async() calls will be done sequentially.

As a workaround I think I can send all branches to myself (spiral call)
and receiving those INVITEs from loopback opensips will create a
separate transaction for every destination so I'll be able to run
async() tasks in parallel and forward a call to every destination
immediately its async() task is finished.


> Hi Vitalii,
>
> The async() statement can be used only in REQUEST route. Still,
> whatever you need to do in terms of async query from branch route can
> also be done from request route.
>
> Regards,
>
> Bogdan-Andrei Iancu
>
> OpenSIPS Founder and Developer
>   http://www.opensips-solutions.com
> OpenSIPS Bootcamp 2018
>   http://opensips.org/training/OpenSIPS_Bootcamp_2018/
>
> On 11/01/2018 01:46 PM, Vitalii Aleksandrov wrote:
>> Hi,
>>
>> I'm a bit new to opensips, while have some experience with kamailio.
>>
>> Trying to figure out whether it's possible to use async() statement
>> from branch_route[].
>>
>> From the documentation I understood that async() functionality is
>> tightly connected to the TM module and creates some context attached
>> to a transaction, suspends it and resumes a transaction on an event.
>> If said above is correct I suppose calling async() from a
>> branch_route[] to suspend only one branch and expect that other
>> branches will continue their normal execution is not what it was
>> designed for..
>>
>> Is there any way to forward a branch while other branches wait for an
>> async event or i/o?
>>
>> Would appreciate any ideas.
>>
>>
>> _______________________________________________
>> Users mailing list
>> [hidden email]
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: async(wait_for_event()) statement in a branch_route[]

Bogdan-Andrei Iancu-2
In reply to this post by Vitalii Aleksandrov
Hi Vitalii,

Yes, that is correct. The idea is you cannot do async() ops in the
branch route as this type of route is strongly interfering with the SIP
signaling - branch route is triggered when a new branch is set out (as a
result of a t_relay) and no signaling operations are allowed (as you are
already doing a signaling op).
Still, this limitation is valid only for async calls () as async is
based on the transaction status. But, you can do regular sync() queries
from the branch route, with a risk of blocking the processes of opensips.

The spiraling (as you described) is also a valid option, but you need to
be a bit careful with the script logic to be sure you do not mix the
loops :)

Regards,

Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
   http://www.opensips-solutions.com
OpenSIPS Bootcamp 2018
   http://opensips.org/training/OpenSIPS_Bootcamp_2018/

On 11/02/2018 12:04 PM, Vitalii Aleksandrov wrote:

> Hi Bogdan,
>
> Ok. Let's say I have 5 branches and before calling t_relay() want to
> iterate over branches and do some async() action. From my
> understanding if I do something via async() it will suspend the whole
> transaction with all branches and if I need the same action for every
> branch it will create a big PDD because all async() calls will be done
> sequentially.
>
> As a workaround I think I can send all branches to myself (spiral
> call) and receiving those INVITEs from loopback opensips will create a
> separate transaction for every destination so I'll be able to run
> async() tasks in parallel and forward a call to every destination
> immediately its async() task is finished.
>
>
>> Hi Vitalii,
>>
>> The async() statement can be used only in REQUEST route. Still,
>> whatever you need to do in terms of async query from branch route can
>> also be done from request route.
>>
>> Regards,
>>
>> Bogdan-Andrei Iancu
>>
>> OpenSIPS Founder and Developer
>>   http://www.opensips-solutions.com
>> OpenSIPS Bootcamp 2018
>>   http://opensips.org/training/OpenSIPS_Bootcamp_2018/
>>
>> On 11/01/2018 01:46 PM, Vitalii Aleksandrov wrote:
>>> Hi,
>>>
>>> I'm a bit new to opensips, while have some experience with kamailio.
>>>
>>> Trying to figure out whether it's possible to use async() statement
>>> from branch_route[].
>>>
>>> From the documentation I understood that async() functionality is
>>> tightly connected to the TM module and creates some context attached
>>> to a transaction, suspends it and resumes a transaction on an event.
>>> If said above is correct I suppose calling async() from a
>>> branch_route[] to suspend only one branch and expect that other
>>> branches will continue their normal execution is not what it was
>>> designed for..
>>>
>>> Is there any way to forward a branch while other branches wait for
>>> an async event or i/o?
>>>
>>> Would appreciate any ideas.
>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> [hidden email]
>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users