[asterisk-users] (fast) AGI and AMI synchronization ?

Rizwan Hisham rizwanhasham at gmail.com
Tue Mar 8 06:54:32 CST 2011


You can use threads and queues in your program to interface with AMI. Your
main thread should get all the events from * and based on some logic enqueue
it. Some other thread should be listening to the queue and in that thread
you are free to read the input whenever you want. This way you are free to
keep listening from the AMI as fast as you can and also your other thread
will process them at its own pace.

Cheers

On Tue, Mar 8, 2011 at 5:27 PM, Faisal Hanif <faisal at vopium.com> wrote:

> AMI is single threaded link so waiting on it will bring things to hang mode
> but FastAGI & dialplan is multithread. Better to manage all info by AMI in
> a
> local hash or array and use sleep/waiting on AGI till required info
> populated to hash/array by AMI.
>
> -----Original Message-----
> From: asterisk-users-bounces at lists.digium.com
> [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Corentin Le
> Gall
> Sent: Tuesday, March 08, 2011 4:31 PM
> To: asterisk-users at lists.digium.com
> Subject: [asterisk-users] (fast) AGI and AMI synchronization ?
>
> Hi,
>
> I've been developing some CTI software around asterisk for a while, mainly
> with the help of AMI and fast AGI.
> It works quite fine, but I have some trouble sometimes with the
> un-synchronized property of these 2.
> Let me explain, we have a dialplan like this one :
>
> exten = s,n,UserEvent(useful_input_data)
> (...) a few actions
> exten = s,n,AGI(agi://127.0.0.1:3333/fetch,queuename)
>
> The idea is to setup a "cti server" that talks with both AMI and AGI
> channels, the first one mainly when one just want to send some data from
> asterisk to the "cti server", and the second one when the dialplan needs
> some data from this server.
>
> My issue is that the AGI requests are received (from the CTI server point
> of
> vue) a little bit before the AMI events. In most cases, I don't really care
> because it is only "a little", and the data asterisk needs to fetch from
> the
> AGI are set on time. But sometimes not, especially in cases like above,
> when
> there are only a few dialplan lines between UserEvent and AGI ...
>
> In order to handle that, I thought "let's make a sync/meeting point, with
> the help of the AMI NewExten event, when the app is AGI".
> The idea would be to keep the AGI connection open as long as the good AMI
> NewExten event is not received, then to reply and close it, in order for
> the
> dialplan to proceed.
> However, when trying to do this, nothing more occurs on the AMI connection,
> thus I come to a deadlock ...
>
> My question is then, before switching to -dev issues : is there an option
> somewhere to handle this, whether on the AMI or on the AGI side ?
> The asterisk version we've been using for a long time is 1.4 and my current
> attempts are done on 1.8 branch.
>
> Thanks,
> --
> Corentin LE GALL
> Proformatique (Groupe Avencall) - 10bis rue Lucien Voilin - F-92800 Puteaux
> Tel (+33/0)1.41.38.99.60 - Fax (+33/0)1.41.38.99.70 http://wiki.xivo.fr
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New
> to
> Asterisk? Join us for a live introductory webinar every Thurs:
>               http://www.asterisk.org/hello
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users
>
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> New to Asterisk? Join us for a live introductory webinar every Thurs:
>               http://www.asterisk.org/hello
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users
>



-- 
Best Ragards
Rizwan Qureshi
VoIP/Asterisk Engineer
Axvoice Inc.
V: +92 (0) 3333 6767 26
E: rizwanhasham at gmail.com
W: www.axvoice.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20110308/265d5520/attachment.htm>


More information about the asterisk-users mailing list