Re: [Asterisk-java-devel] Error to process new calls on AsyncAgiServer
Brought to you by:
srt
From: Yves A. <yv...@gm...> - 2012-10-17 10:48:45
|
Hi, the code is not complete and I therefore cannot understand dependencies, what is called when and so on. help stucks here... but, as far as I can see... your code seems "overloaded"... or "very complicated"... meaning that the things you are trying to achive could be done "easier" and therefor even cleaner... but that reflects just my opinion after seeing the codefragments, without knowing exactly what your objective is... maybe you could clear that and I can further assist you. regards, yves Am 16.10.2012 19:13, schrieb Jeryes .: > Thank you for the quick reply! > > I've just migrated to AsyncAgi, and I only changed the way the > application connects to Asterisk, and how the application gets the > channelName and uniqueID from AgiRequest, on service event. Is there > other alterations that impacts on the migration from Sync to Async. Do > I need to change the way that I invoke the commands on channel, like > answer, streamFile, rec, playMusicOnHold ? > The main idea to migrate to AsyncAgi, in a first step, is to process > some events on AMI, like stoped MusicOnHold, which is not delivered to > AMI Listener when using Sync connection. > > Brett, > > I reduced the pool to 5 threads and I couldn't reproduce that > situation, maybe it is occurring in some exclusive types of call > processing, so I gotta do more tests... > Thanks! > > AgiScript: > > > public class AsteriskServer extends BaseAgiScript > { > > private CallEventListener callEventListener; > > public void service(AgiRequest request, AgiChannel channel) throws > AgiException > { > * // I didn't find a better way the get those values...* > *String[] paramList = ((String) > request.getRequest().get("request")).split("\n"); > String channelName = paramList[1].split(":")[1].trim(); > String uniqueID = paramList[4].split(":")[1].trim();* > String fromAddress = channel.getVariable("SIP_HEADER(FROM)"); > String toAddress = channel.getVariable("SIP_HEADER(TO)"); > > // The event is added into a queue and treated by another > threadpool, to release the current thread. > callEventListener.callCreated(request, channel, fromAddress, > toAddress, channelName, uniqueID); > > *// keep channel stuck while process the call, that will be released > on disconnect command* > waitProcessing(channel); > } > > * //Command executed by CallEventListener to release the channel.* > public void disconnect(AgiChannel channel) > { > processingDone(channel); > } > > public void *waitProcessing*(AgiChannel channel) throws > InterruptedException > { > System.out.println("wait until call get released..."); > synchronized (channel) > { > channel.wait(); > } > } > > public void *processingDone*(AgiChannel channel) > { > System.out.println("releasing call..."); > synchronized (channel) > { > channel.notify(); > } > } > > public void addCallEventListener(CallEventListener callEventListener) > { > this.callEventListener = callEventListener; > } > > public void startup() > { > new AsyncAsteriskServerConnector(this, "192.168.192.32", > "dev", "dev").connect(); > } > > class *AsyncAsteriskServerConnector* implements Runnable > { > private BaseAgiScript agiScript; > private ManagerConnection connection; > > public AsyncAsteriskServerConnector(BaseAgiScript agiScript, > String ip, String username, String passwd) > { > this.agiScript = agiScript; > connection = new DefaultManagerConnection(ip, username, > passwd); > } > > public ManagerConnection connect() > { > new Thread(this).start(); > return connection; > } > > public void run() > { > AsyncAgiServer agiServer = new AsyncAgiServer(agiScript); > connection.addEventListener(agiServer); > > try > { > connection.login(); > synchronized (this.agiScript) > { > agiScript.wait(); > } > } catch (Throwable e) {e.printStackTrace();} > } > } > } > > > 2012/10/15 Brett Sutton <bs...@no... > <mailto:bs...@no...>> > > I would suggest that you get something like Visual VM which will > give you and good idea of what your application is doing. > Of course any decent dev environment like eclipse will tell you > what threads a running and you can then pause them to see if and > where they are stuck. > > Also reduce the pool to a really small number (10) and see if it > gets stuck sooner. > > Brett > > > On 16/10/12 09:18, Jeryes . wrote: >> Hi All! >> >> I'm working with asterisk 1.6.3 and asterisk-java 1.0.0.M3, and I >> have an implementation of BaseAgiScript, that connects to >> Asterisk with AsyncAgiServer. After some calls, between 100 ou >> 200 , the agiscript stops to receive the */service/* events, this >> error log is thrown instead: >> >> 16:19:33,040 ERROR (Asterisk-Java ManagerConnection-1-Reader-0) >> [STDERR] 137706502 [Asterisk-Java ManagerConnection-1-Reader-0] >> WARN org.asteriskjava.fastagi.AsyncAgiServer - Unable to execute >> org.asteriskjava.fastagi.internal.AsyncAgiConnectionHandler >> 16:19:33,040 ERROR (Asterisk-Java ManagerConnection-1-Reader-0) >> [STDERR] java.util.concurrent.RejectedExecutionException >> 16:19:33,041 ERROR (Asterisk-Java ManagerConnection-1-Reader-0) >> [STDERR] at >> java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1768) >> >> 16:19:33,041 ERROR (Asterisk-Java ManagerConnection-1-Reader-0) >> [STDERR] at >> java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:767) >> >> 16:19:33,041 ERROR (Asterisk-Java ManagerConnection-1-Reader-0) >> [STDERR] at >> java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:658) >> >> 16:19:33,041 ERROR (Asterisk-Java ManagerConnection-1-Reader-0) >> [STDERR] at >> org.asteriskjava.fastagi.AbstractAgiServer.execute(AbstractAgiServer.java:137) >> >> 16:19:33,041 ERROR (Asterisk-Java ManagerConnection-1-Reader-0) >> [STDERR] at >> org.asteriskjava.fastagi.AsyncAgiServer.handleAsyncAgiEvent(AsyncAgiServer.java:89) >> >> 16:19:33,041 ERROR (Asterisk-Java ManagerConnection-1-Reader-0) >> [STDERR] at >> org.asteriskjava.fastagi.AsyncAgiServer.onManagerEvent(AsyncAgiServer.java:68) >> >> 16:19:33,041 ERROR (Asterisk-Java ManagerConnection-1-Reader-0) >> [STDERR] at >> org.asteriskjava.manager.internal.ManagerConnectionImpl.fireEvent(ManagerConnectionImpl.java:1245) >> >> 16:19:33,041 ERROR (Asterisk-Java ManagerConnection-1-Reader-0) >> [STDERR] at >> org.asteriskjava.manager.internal.ManagerConnectionImpl.dispatchEvent(ManagerConnectionImpl.java:1229) >> >> 16:19:33,042 ERROR (Asterisk-Java ManagerConnection-1-Reader-0) >> [STDERR] at >> org.asteriskjava.manager.internal.ManagerReaderImpl.run(ManagerReaderImpl.java:220) >> >> 16:19:33,042 ERROR (Asterisk-Java ManagerConnection-1-Reader-0) >> [STDERR] at java.lang.Thread.run(Thread.java:619) >> >> >> The pool size is 1000, configured on file fastagi.properties: >> poolSize=1000 >> >> Can it be stuck threads, that should be released? Is there any >> way to check how many threads of the pool are in use? >> >> Thanks in advance! >> >> Regards >> Jeryes >> >> >> >> ------------------------------------------------------------------------------ >> Don't let slow site performance ruin your business. Deploy New Relic APM >> Deploy New Relic app performance management and know exactly >> what is happening inside your Ruby, Python, PHP, Java, and .NET app >> Try New Relic at no cost today and get our sweet Data Nerd shirt too! >> http://p.sf.net/sfu/newrelic-dev2dev >> >> >> _______________________________________________ >> Asterisk-java-devel mailing list >> Ast...@li... <mailto:Ast...@li...> >> https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > > > ------------------------------------------------------------------------------ > Don't let slow site performance ruin your business. Deploy New > Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > <mailto:Ast...@li...> > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > > > > > ------------------------------------------------------------------------------ > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > > > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel |