<< AGI scripts in Groovy | Home | MD5 Authentication Bug in Asterisk >>

Integrating AGI and Apache Tomcat

Using Spring Framework and AgiServerThread

I've already described how the Spring Framework can be used to externalize your AGI configuration. That blog entry asumed you are running your AGI server as a stand alone application. What is the best way to run it within an app server or a servlet container like Tomcat however?

When you just place the snippet from here into your applicationContext.xml you will notice that Tomcat will hang on start up and that you won't be able to shut it down properly.
The reason for this is that the AGI server is blocking Tomcat and waits for incoming AGI requests. To solve this you have to wrap your AgiServer in a thread so that it runs in the background. Asterisk-Java comes with a utility class called AgiServerThread that just does this.

So the following snippet will work as expected:

<bean class="org.asteriskjava.fastagi.AgiServerThread"
      init-method="startup" destroy-method="shutdown">
    <property name="agiServer" ref="agiServer"/>
</bean>

<bean id="agiServer" class="org.asteriskjava.fastagi.DefaultAgiServer">
    <property name="bindPort" value="4573"/>
    <property name="mappingStrategy">
        <bean class="xxx">
...
        </bean>
    </property>
</bean>

References:



Re: Integrating AGI and Apache Tomcat

Thank you. This is helpful

Re: Integrating AGI and Apache Tomcat

Thanks for this great job Stefan, I'm voip developer working with AGI and I read your blog about connecting AGI with Tomcat using spring framework and this part is not clear for me, so, please if you could guide me what and how to do the integration with Tomcat. Thanks!

Re: Integrating AGI and Apache Tomcat

Could you be a bit more specific about what is not clear to you? Did you already read this posting?

Add a comment Send a TrackBack