"My experience with Asterisk AGI Programing" -Blog

[quote=“Lord Straud”]If you’ve visited my links (and I hope you did) you may have learned about Asterisk, The Open-Source PBX. Asterisk is one of the most powerfull tools I’ve encountered during the 15 years of my IT life (has it been that long?). However, like any other Open-Source technology, it has it’s own quirks. In this page I will try to write my experience with Asterisk, and also try to put in my 2c on various issues currently going on within the Asterisk Community.

I will start off by saying this: DON’T USE JAVA! If you really must use JAVA, use FastAGI instead of AGI.

Did I already say - DON’T USE JAVA![/quote]

Source

Any ideas why this guy says not to use Java? No explanation in his post.

Not really… I use php on the agi…

so far no problems :smile:

I have used both with equal success.

The Java JVM does create a lot of overhead, and I think each instance of AGI should launch a new JVM. It is best that the JVM should already be running and that you have FastAGI to connect to it via a socket.

This is the only thing I can think of.

[quote=“shep”]The Java JVM does create a lot of overhead, and I think each instance of AGI should launch a new JVM. It is best that the JVM should already be running and that you have FastAGI to connect to it via a socket.

This is the only thing I can think of.[/quote]

I agree that if using Java it should be with FastAGI and most likely on a seperate server. Although I do not believe that an entirely new JVM launches upon each call, but will need to go back and check.

Just not sure why the poster believes it should be avoided like the plague. May be legitimate, but probably more of a ‘how it was used’/design implementation issue.

PS - This is the one I have used: asterisk-java.sourceforge.net/

Maybe some people just like that kind of Java-bashing :wink:

I discussed the options to interface Asterisk some time ago when designing Asterisk-Java:

“[…] The second approach is to write AGI (Asterisk Gateway Interface) scripts. An AGI script is to Asterisk what a CGI script is to an HTTP server. You can think of AGI as a means to make your dialplan more dynamic by handing control to an external process. As with CGI in its early days Asterisk had to spawn a new short lived process for each AGI request. When using external application that consume a lot of resources at startup (like spawning a Java Virtual Machine when launching a Java application) this approach has major drawbacks. These shortcoming have been mitigated with the introduction of FastAGI that doesn’t spawn a new process for each request but communicates with a long running process via TCP/IP.” (source: asterisk-java.sourceforge.net/design.html )

That said you should always avoid plain AGI (coz you are starting a new *nix process for every request). When using FastAGI no additional process is started nor any JavaVM. Another issue with plain AGI is that you really don’t want your AGI scripts to run on the same server as the PBX…

Summary: if you think before you start coding you can write well performing applications with almost any technology, if you dont you end up writing foolish blog entries :smile:

Agreed.