[asterisk-dev] Dialplan AGI with SIP channels blocking if AGI already running - parallellism not possible?

Matthew Jordan mjordan at digium.com
Wed Apr 3 11:14:31 CDT 2013


On 04/03/2013 09:58 AM, Johan Sandgren wrote:
> Thanks for noticing Michael L. Young.
> 
> Retested it with the right address also 2nd SIP MESSAGE.
> Still same result, I attach the new logs which show this.
> I see it stops after "Looking for 1000 in sipmessage".
> Nothing more happens. There's the stopping point. 
> Should it work?
> 

Unfortunately, no.

In the case of messages (regardless of the underlying technology - XMPP
or SIP), a special "Message" channel driver in the core of Asterisk is
responsible for servicing the text messages in the dialplan. When a text
message is received in the SIP channel driver/XMPP stack, it is queued
up for servicing by a taskprocesser, which is a construct that
serializes requests and dispatches them on a single thread. In the
messaging core, this entails creating an instance of the Message channel
and and running the dialplan specified by the text message. When the
dialplan is finished, it returns, and the next text message is serviced.

This means that each text message is serviced in the sequence that they
arrive, and that two text messages are not serviced in parallel. The
design here never envisioned text message handling to become long
running events.

You may be able to work around this by deferring the work onto another
channel. To do this, you could try Originating a channel to run your AGI
- something like this:

same => 1000,1,NoOp(Entry point for the message)
; Assuming you need the message data, you could save them
; off into inheritable channel variables
same => n,Set(__MY_BODY=MESSAGE(body))
same => n,Originate(Local/message_handler at default,app,Echo)
same => n,Hangup()

same => message_handler,1,NoOp()
same => n,Answer()	; This will release the Originate in 1000
same => n,AGI(...)
same => n,Hangup()

Matt

-- 
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org





More information about the asterisk-dev mailing list