[asterisk-dev] ARI StasisEnd event vs. channel variables

Joshua Colp jcolp at digium.com
Tue Oct 18 16:02:41 CDT 2016


Matthew Jordan wrote:

<snip>

> There are a few wrinkles with emitting channel variables with
> arbitrary events (of which StasisEnd would qualify).
>
> When an event is emitted out of the APIs, it's typically being done so
> as a result of a message having been published on the Stasis message
> bus. The messages on the bus don't contain a reference to a channel,
> but rather a snapshot of the channel. Those snapshots, by default,
> don't contain any channel variables, primarily for performance
> reasons. Additionally, since dialplan functions can be freely
> interchanged with channel variables, it's impossible (or very costly)
> to evaluate dialplan function expressions on each snapshot creation.
>
> Unfortunately, you really do need to rely on the messages coming
> across the bus. By the time code is processing the sending of a
> StasisEnd event, the ast_channel itself may already be gone. As such,
> the variables have to be stored on the snapshot in some fashion.
>
> AMI accomplished this by creating a core concept known as 'manager
> variables'. These are set directly on the ast_channel structure, and -
> when a snapshot is created - are evaluated and copied onto the
> snapshot. Again, this is a rather costly operation, but it does limit
> the impact of including variables on messages, as you have to
> explicitly tell Asterisk which state you want transmitted along with
> the channel.
>
> If we wanted a similar concept in ARI, the manager variables could be
> reused. I would note that you absolutely will take a performance hit
> when using them - building and conveying that much state in every
> event is not cheap. Because StasisEnd is rather 'special' - often the
> channel core isn't aware of it - I'm not sure how you would convey
> variables only on that event and not on all the rest.

The actual raising of StasisEnd is explicitly done inside of Stasis and 
lives there. When raised the channel is there and valid. It currently 
uses a channel blob as the payload but this could be changed to 
something else that would allow channel variables (only channel 
variables explicitly set on the channel) to also be added. This would 
scope the channel variables addition to only StasisEnd. Now... if we 
wanted channel variables on every message... then yeah, it would be 
difficult.

-- 
Joshua Colp
Digium, Inc. | Senior Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - US
Check us out at: www.digium.com & www.asterisk.org




More information about the asterisk-dev mailing list