Thread: [Asterisk-java-devel] Does each received event creates a new Thread?
Brought to you by:
srt
From: Jose B. <pe...@gm...> - 2016-02-11 10:32:35
|
Hello! With this lines of code, when I receive a new Event, is a new Thread created for each "handleEvent()" ? Or will "handleEvent()" start to run when the previous "handleEvent" is completely finished? public class AsteriskJava implements ManagerEventListener { ... ... public static main () { try { AsteriskJava asteriskJava = new AsteriskJava(); asteriskJava.run(); } catch { } } @Override public void onManagerEvent(ManagerEvent event) { if (event.getClass() == NewExtenEvent.class) { *handleEvent((NewExtenEvent) event);* } else if ((event.getClass() == ... ... ... } protected void *handleEvent (NewExtenEvent event)* { } ... ... } ___ ___ Thank you. |
From: S. B. S. <bs...@no...> - 2016-02-12 00:25:33
|
No, events are generated from a single 'event handling loop'. So whilst the event will generated in a different thread to you main thread all events come from one thread. Note: this does have implications when processing events. If the processing logic does long running tasks then you can block the event thread. If you do this for too long than asterisk will disconnect the manager connection. Brett On 11/02/16 21:32, Jose Baez wrote: > Hello! > > > With this lines of code, when I receive a new Event, is a new Thread > created for each "handleEvent()" ? Or will "handleEvent()" start to > run when the previous "handleEvent" is completely finished? > > public class AsteriskJava implements ManagerEventListener { > > ... > ... > > public static main () { > > try { > > AsteriskJava asteriskJava = new AsteriskJava(); > asteriskJava.run(); > > } catch { } > } > > @Override > public void onManagerEvent(ManagerEvent event) { > > if (event.getClass() == NewExtenEvent.class) { > *handleEvent((NewExtenEvent) event);* > } > else if ((event.getClass() == ... > ... > ... > > } > > protected void *handleEvent (NewExtenEvent event)* { } > ... > ... > > } > ___ > ___ > > > > Thank you. > > > > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > > > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel |
From: S. B. S. <bs...@no...> - 2016-02-12 02:55:37
|
By your code won't work as you haven't registered yourself as a listener. Have a look at the Hello Events example here; https://maven.reucon.com/projects/public/asterisk-java/1.0.0.CI-SNAPSHOT/asterisk-java/tutorial.html On 12/02/16 11:09, S. Brett Sutton wrote: > No, events are generated from a single 'event handling loop'. > > So whilst the event will generated in a different thread to you main > thread all events come from one thread. > > Note: this does have implications when processing events. If the > processing logic does long running tasks then you can block the event > thread. If you do this for too long than asterisk will disconnect the > manager connection. > > Brett > > On 11/02/16 21:32, Jose Baez wrote: >> Hello! >> >> >> With this lines of code, when I receive a new Event, is a new Thread >> created for each "handleEvent()" ? Or will "handleEvent()" start to >> run when the previous "handleEvent" is completely finished? >> >> public class AsteriskJava implements ManagerEventListener { >> >> ... >> ... >> >> public static main () { >> >> try { >> >> AsteriskJava asteriskJava = new AsteriskJava(); >> asteriskJava.run(); >> >> } catch { } >> } >> >> @Override >> public void onManagerEvent(ManagerEvent event) { >> >> if (event.getClass() == NewExtenEvent.class) { >> *handleEvent((NewExtenEvent) event);* >> } >> else if ((event.getClass() == ... >> ... >> ... >> >> } >> >> protected void *handleEvent (NewExtenEvent event)* { } >> ... >> ... >> >> } >> ___ >> ___ >> >> >> >> Thank you. >> >> >> >> >> >> ------------------------------------------------------------------------------ >> Site24x7 APM Insight: Get Deep Visibility into Application Performance >> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month >> Monitor end-to-end web transactions and take corrective actions now >> Troubleshoot faster and improve end-user experience. Signup Now! >> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 >> >> >> _______________________________________________ >> Asterisk-java-devel mailing list >> Ast...@li... >> https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > |
From: Robert S. <rs...@as...> - 2016-02-12 03:30:32
|
Asterisk-Java-1.0.0-final has been release to Maven Central here <http://search.maven.org/#artifactdetails%7Corg.asteriskjava%7Casterisk-java%7C1.0.0-final%7Cjar> |You can add Asterisk-Java-1.0.0-final to your project simply by adding the xml below to your dependencies section of your projects pom.xml <||dependency||>| |||<||groupId||>org.asteriskjava</||groupId||>| |||<||artifactId||>asterisk-java</||artifactId||>| |||<||version||>1.0.0-final</||version||>| |</||dependency||>| |
From: Jose B. <pe...@gm...> - 2016-02-12 08:14:06
|
Thanks for explanation. So, is it safe to create a new thread inside handleevent() to minimize blocking in main thread? Hehe, the code I posted is a piece of code extracted from full code that it is worlking. :) Thank you. El 12/02/2016 02:56, "S. Brett Sutton" <bs...@no...> escribió: > > By your code won't work as you haven't registered yourself as a listener. > > Have a look at the Hello Events example here; > > https://maven.reucon.com/projects/public/asterisk-java/1.0.0.CI-SNAPSHOT/asterisk-java/tutorial.html > > > > > > > On 12/02/16 11:09, S. Brett Sutton wrote: >> >> No, events are generated from a single 'event handling loop'. >> >> So whilst the event will generated in a different thread to you main thread all events come from one thread. >> >> Note: this does have implications when processing events. If the processing logic does long running tasks then you can block the event thread. If you do this for too long than asterisk will disconnect the manager connection. >> >> Brett >> >> On 11/02/16 21:32, Jose Baez wrote: >>> >>> Hello! >>> >>> >>> With this lines of code, when I receive a new Event, is a new Thread created for each "handleEvent()" ? Or will "handleEvent()" start to run when the previous "handleEvent" is completely finished? >>> >>> public class AsteriskJava implements ManagerEventListener { >>> >>> ... >>> ... >>> >>> public static main () { >>> >>> try { >>> >>> AsteriskJava asteriskJava = new AsteriskJava(); >>> asteriskJava.run(); >>> >>> } catch { } >>> } >>> >>> @Override >>> public void onManagerEvent(ManagerEvent event) { >>> >>> if (event.getClass() == NewExtenEvent.class) { >>> handleEvent((NewExtenEvent) event); >>> } >>> else if ((event.getClass() == ... >>> ... >>> ... >>> >>> } >>> >>> protected void handleEvent (NewExtenEvent event) { } >>> ... >>> ... >>> >>> } >>> ___ >>> ___ >>> >>> >>> >>> Thank you. >>> >>> >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Site24x7 APM Insight: Get Deep Visibility into Application Performance >>> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month >>> Monitor end-to-end web transactions and take corrective actions now >>> Troubleshoot faster and improve end-user experience. Signup Now! >>> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 >>> >>> >>> >>> _______________________________________________ >>> Asterisk-java-devel mailing list >>> Ast...@li... >>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel >> >> > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > |
From: S. B. S. <bs...@no...> - 2016-02-14 20:58:54
|
Yes you can create a new thread within the event handler. But 'safe', that will depend on what you do!!! It is actually often 'necessary' to create a new thread. For instance if you fire an action that needs an event response then you can't do that from the event handler as the event will be blocked because you are in the event handling thread. On 12/02/16 19:13, Jose Baez wrote: > > Thanks for explanation. So, is it safe to create a new thread inside > handleevent() to minimize blocking in main thread? > > Hehe, the code I posted is a piece of code extracted from full code > that it is worlking. :) > > Thank you. > > El 12/02/2016 02:56, "S. Brett Sutton" <bs...@no... > <mailto:bs...@no...>> escribió: > > > > By your code won't work as you haven't registered yourself as a > listener. > > > > Have a look at the Hello Events example here; > > > > > https://maven.reucon.com/projects/public/asterisk-java/1.0.0.CI-SNAPSHOT/asterisk-java/tutorial.html > > > > > > > > > > > > > > On 12/02/16 11:09, S. Brett Sutton wrote: > >> > >> No, events are generated from a single 'event handling loop'. > >> > >> So whilst the event will generated in a different thread to you > main thread all events come from one thread. > >> > >> Note: this does have implications when processing events. If the > processing logic does long running tasks then you can block the event > thread. If you do this for too long than asterisk will disconnect the > manager connection. > >> > >> Brett > >> > >> On 11/02/16 21:32, Jose Baez wrote: > >>> > >>> Hello! > >>> > >>> > >>> With this lines of code, when I receive a new Event, is a new > Thread created for each "handleEvent()" ? Or will "handleEvent()" > start to run when the previous "handleEvent" is completely finished? > >>> > >>> public class AsteriskJava implements ManagerEventListener { > >>> > >>> ... > >>> ... > >>> > >>> public static main () { > >>> > >>> try { > >>> > >>> AsteriskJava asteriskJava = new AsteriskJava(); > >>> asteriskJava.run(); > >>> > >>> } catch { } > >>> } > >>> > >>> @Override > >>> public void onManagerEvent(ManagerEvent event) { > >>> > >>> if (event.getClass() == NewExtenEvent.class) { > >>> handleEvent((NewExtenEvent) event); > >>> } > >>> else if ((event.getClass() == ... > >>> ... > >>> ... > >>> > >>> } > >>> > >>> protected void handleEvent (NewExtenEvent event) { } > >>> ... > >>> ... > >>> > >>> } > >>> ___ > >>> ___ > >>> > >>> > >>> > >>> Thank you. > >>> > >>> > >>> > >>> > >>> > >>> > ------------------------------------------------------------------------------ > >>> Site24x7 APM Insight: Get Deep Visibility into Application Performance > >>> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > >>> Monitor end-to-end web transactions and take corrective actions now > >>> Troubleshoot faster and improve end-user experience. Signup Now! > >>> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > >>> > >>> > >>> > >>> _______________________________________________ > >>> Asterisk-java-devel mailing list > >>> Ast...@li... > <mailto:Ast...@li...> > >>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > >> > >> > > > > > > > ------------------------------------------------------------------------------ > > Site24x7 APM Insight: Get Deep Visibility into Application Performance > > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > > Monitor end-to-end web transactions and take corrective actions now > > Troubleshoot faster and improve end-user experience. Signup Now! > > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > > _______________________________________________ > > Asterisk-java-devel mailing list > > Ast...@li... > <mailto:Ast...@li...> > > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > > > > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > > > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel |
From: Jose B. <pe...@gm...> - 2016-02-14 21:17:57
|
Yes, I know. I took care of that already. Thanks. But if i send and action that gets a 'response' (not an event) I guess there is no problem to do it inside event handler, isn't it? El 14/02/2016 20:59, "S. Brett Sutton" <bs...@no...> escribió: > Yes you can create a new thread within the event handler. > > But 'safe', that will depend on what you do!!! > > It is actually often 'necessary' to create a new thread. For instance if > you fire an action that needs an event response then you can't do that from > the event handler as the event will be blocked because you are in the event > handling thread. > > On 12/02/16 19:13, Jose Baez wrote: > > Thanks for explanation. So, is it safe to create a new thread inside > handleevent() to minimize blocking in main thread? > > Hehe, the code I posted is a piece of code extracted from full code that > it is worlking. :) > > Thank you. > > El 12/02/2016 02:56, "S. Brett Sutton" <bs...@no...> escribió: > > > > By your code won't work as you haven't registered yourself as a listener. > > > > Have a look at the Hello Events example here; > > > > > https://maven.reucon.com/projects/public/asterisk-java/1.0.0.CI-SNAPSHOT/asterisk-java/tutorial.html > > > > > > > > > > > > > > On 12/02/16 11:09, S. Brett Sutton wrote: > >> > >> No, events are generated from a single 'event handling loop'. > >> > >> So whilst the event will generated in a different thread to you main > thread all events come from one thread. > >> > >> Note: this does have implications when processing events. If the > processing logic does long running tasks then you can block the event > thread. If you do this for too long than asterisk will disconnect the > manager connection. > >> > >> Brett > >> > >> On 11/02/16 21:32, Jose Baez wrote: > >>> > >>> Hello! > >>> > >>> > >>> With this lines of code, when I receive a new Event, is a new Thread > created for each "handleEvent()" ? Or will "handleEvent()" start to run > when the previous "handleEvent" is completely finished? > >>> > >>> public class AsteriskJava implements ManagerEventListener { > >>> > >>> ... > >>> ... > >>> > >>> public static main () { > >>> > >>> try { > >>> > >>> AsteriskJava asteriskJava = new AsteriskJava(); > >>> asteriskJava.run(); > >>> > >>> } catch { } > >>> } > >>> > >>> @Override > >>> public void onManagerEvent(ManagerEvent event) { > >>> > >>> if (event.getClass() == NewExtenEvent.class) { > >>> handleEvent((NewExtenEvent) event); > >>> } > >>> else if ((event.getClass() == ... > >>> ... > >>> ... > >>> > >>> } > >>> > >>> protected void handleEvent (NewExtenEvent event) { } > >>> ... > >>> ... > >>> > >>> } > >>> ___ > >>> ___ > >>> > >>> > >>> > >>> Thank you. > >>> > >>> > >>> > >>> > >>> > >>> > ------------------------------------------------------------------------------ > >>> Site24x7 APM Insight: Get Deep Visibility into Application Performance > >>> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > >>> Monitor end-to-end web transactions and take corrective actions now > >>> Troubleshoot faster and improve end-user experience. Signup Now! > >>> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > >>> > >>> > >>> > >>> _______________________________________________ > >>> Asterisk-java-devel mailing list > >>> Ast...@li... > >>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > >> > >> > > > > > > > ------------------------------------------------------------------------------ > > Site24x7 APM Insight: Get Deep Visibility into Application Performance > > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > > Monitor end-to-end web transactions and take corrective actions now > > Troubleshoot faster and improve end-user experience. Signup Now! > > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > > _______________________________________________ > > Asterisk-java-devel mailing list > > Ast...@li... > > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > > > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now!http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > > > > _______________________________________________ > Asterisk-java-devel mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > > > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > > |
From: Robert S. <rs...@as...> - 2016-02-14 22:34:29
|
The problem is that the reader thread for the asterisk-manager connection is used to handle the event, so if you push out any manager command/action you can't get the response because you are holding the reader thread. You must therefore do it on a separate asterisk-manager connection - and I would suggest separate thread as well, I can't recall if there is anything like ThreadLocal used in the manager connection implementation but it would be the safest option. On 15/02/16 08:17, Jose Baez wrote: > > Yes, I know. I took care of that already. > Thanks. > > But if i send and action that gets a 'response' (not an event) I guess > there is no problem to do it inside event handler, isn't it? > > El 14/02/2016 20:59, "S. Brett Sutton" <bs...@no... > <mailto:bs...@no...>> escribió: > > Yes you can create a new thread within the event handler. > > But 'safe', that will depend on what you do!!! > > It is actually often 'necessary' to create a new thread. For > instance if you fire an action that needs an event response then > you can't do that from the event handler as the event will be > blocked because you are in the event handling thread. > > On 12/02/16 19:13, Jose Baez wrote: >> >> Thanks for explanation. So, is it safe to create a new thread >> inside handleevent() to minimize blocking in main thread? >> >> Hehe, the code I posted is a piece of code extracted from full >> code that it is worlking. :) >> >> Thank you. >> >> El 12/02/2016 02:56, "S. Brett Sutton" <bs...@no... >> <mailto:bs...@no...>> escribió: >> > >> > By your code won't work as you haven't registered yourself as a >> listener. >> > >> > Have a look at the Hello Events example here; >> > >> > >> https://maven.reucon.com/projects/public/asterisk-java/1.0.0.CI-SNAPSHOT/asterisk-java/tutorial.html >> > >> > >> > >> > >> > >> > >> > On 12/02/16 11:09, S. Brett Sutton wrote: >> >> >> >> No, events are generated from a single 'event handling loop'. >> >> >> >> So whilst the event will generated in a different thread to >> you main thread all events come from one thread. >> >> >> >> Note: this does have implications when processing events. If >> the processing logic does long running tasks then you can block >> the event thread. If you do this for too long than asterisk will >> disconnect the manager connection. >> >> >> >> Brett >> >> >> >> On 11/02/16 21:32, Jose Baez wrote: >> >>> >> >>> Hello! >> >>> >> >>> >> >>> With this lines of code, when I receive a new Event, is a new >> Thread created for each "handleEvent()" ? Or will "handleEvent()" >> start to run when the previous "handleEvent" is completely finished? >> >>> >> >>> public class AsteriskJava implements ManagerEventListener { >> >>> >> >>> ... >> >>> ... >> >>> >> >>> public static main () { >> >>> >> >>> try { >> >>> >> >>> AsteriskJava asteriskJava = new AsteriskJava(); >> >>> asteriskJava.run(); >> >>> >> >>> } catch { } >> >>> } >> >>> >> >>> @Override >> >>> public void onManagerEvent(ManagerEvent event) { >> >>> >> >>> if (event.getClass() == NewExtenEvent.class) { >> >>> handleEvent((NewExtenEvent) event); >> >>> } >> >>> else if ((event.getClass() == ... >> >>> ... >> >>> ... >> >>> >> >>> } >> >>> >> >>> protected void handleEvent (NewExtenEvent event) { } >> >>> ... >> >>> ... >> >>> >> >>> } >> >>> ___ >> >>> ___ >> >>> >> >>> >> >>> >> >>> Thank you. >> >>> >> >>> >> >>> >> >>> >> >>> >> >>> >> ------------------------------------------------------------------------------ >> >>> Site24x7 APM Insight: Get Deep Visibility into Application >> Performance >> >>> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month >> >>> Monitor end-to-end web transactions and take corrective >> actions now >> >>> Troubleshoot faster and improve end-user experience. Signup Now! >> >>> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 >> >>> >> >>> >> >>> >> >>> _______________________________________________ >> >>> Asterisk-java-devel mailing list >> >>> Ast...@li... >> <mailto:Ast...@li...> >> >>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel >> >> >> >> >> > >> > >> > >> ------------------------------------------------------------------------------ >> > Site24x7 APM Insight: Get Deep Visibility into Application >> Performance >> > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month >> > Monitor end-to-end web transactions and take corrective actions now >> > Troubleshoot faster and improve end-user experience. Signup Now! >> > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 >> > _______________________________________________ >> > Asterisk-java-devel mailing list >> > Ast...@li... >> <mailto:Ast...@li...> >> > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel >> > >> >> >> >> ------------------------------------------------------------------------------ >> Site24x7 APM Insight: Get Deep Visibility into Application Performance >> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month >> Monitor end-to-end web transactions and take corrective actions now >> Troubleshoot faster and improve end-user experience. Signup Now! >> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 >> >> >> _______________________________________________ >> Asterisk-java-devel mailing list >> Ast...@li... >> <mailto:Ast...@li...> >> https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > <mailto:Ast...@li...> > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > > > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel |
From: Jose B. <pe...@gm...> - 2016-02-25 12:49:24
|
*> You must therefore do it on a separate asterisk-manager connection* *> - and I would suggest separate thread as well* *>* Yes. I had to do that. In scenarios with high load, I got "timeout exception" when sending an action to get a response, using one managerConnection. It happened when I received many many events in same second. With a second managerConnection (which does not receive any events) now it is working OK. Thank you! :) On 14 February 2016 at 22:34, Robert Sutton <rs...@as...> wrote: > The problem is that the reader thread for the asterisk-manager connection > is used to handle the event, so if you push out any manager command/action > you can't get the response because you are holding the reader thread. > > You must therefore do it on a separate asterisk-manager connection - and I > would suggest separate thread as well, I can't recall if there is anything > like ThreadLocal used in the manager connection implementation but it would > be the safest option. > > > On 15/02/16 08:17, Jose Baez wrote: > > Yes, I know. I took care of that already. > Thanks. > > But if i send and action that gets a 'response' (not an event) I guess > there is no problem to do it inside event handler, isn't it? > > El 14/02/2016 20:59, "S. Brett Sutton" <bs...@no...> escribió: > >> Yes you can create a new thread within the event handler. >> >> But 'safe', that will depend on what you do!!! >> >> It is actually often 'necessary' to create a new thread. For instance if >> you fire an action that needs an event response then you can't do that from >> the event handler as the event will be blocked because you are in the event >> handling thread. >> >> On 12/02/16 19:13, Jose Baez wrote: >> >> Thanks for explanation. So, is it safe to create a new thread inside >> handleevent() to minimize blocking in main thread? >> >> Hehe, the code I posted is a piece of code extracted from full code that >> it is worlking. :) >> >> Thank you. >> >> El 12/02/2016 02:56, "S. Brett Sutton" < <bs...@no...> >> bs...@no...> escribió: >> > >> > By your code won't work as you haven't registered yourself as a >> listener. >> > >> > Have a look at the Hello Events example here; >> > >> > >> https://maven.reucon.com/projects/public/asterisk-java/1.0.0.CI-SNAPSHOT/asterisk-java/tutorial.html >> > >> > >> > >> > >> > >> > >> > On 12/02/16 11:09, S. Brett Sutton wrote: >> >> >> >> No, events are generated from a single 'event handling loop'. >> >> >> >> So whilst the event will generated in a different thread to you main >> thread all events come from one thread. >> >> >> >> Note: this does have implications when processing events. If the >> processing logic does long running tasks then you can block the event >> thread. If you do this for too long than asterisk will disconnect the >> manager connection. >> >> >> >> Brett >> >> >> >> On 11/02/16 21:32, Jose Baez wrote: >> >>> >> >>> Hello! >> >>> >> >>> >> >>> With this lines of code, when I receive a new Event, is a new Thread >> created for each "handleEvent()" ? Or will "handleEvent()" start to run >> when the previous "handleEvent" is completely finished? >> >>> >> >>> public class AsteriskJava implements ManagerEventListener { >> >>> >> >>> ... >> >>> ... >> >>> >> >>> public static main () { >> >>> >> >>> try { >> >>> >> >>> AsteriskJava asteriskJava = new AsteriskJava(); >> >>> asteriskJava.run(); >> >>> >> >>> } catch { } >> >>> } >> >>> >> >>> @Override >> >>> public void onManagerEvent(ManagerEvent event) { >> >>> >> >>> if (event.getClass() == NewExtenEvent.class) { >> >>> handleEvent((NewExtenEvent) event); >> >>> } >> >>> else if ((event.getClass() == ... >> >>> ... >> >>> ... >> >>> >> >>> } >> >>> >> >>> protected void handleEvent (NewExtenEvent event) { } >> >>> ... >> >>> ... >> >>> >> >>> } >> >>> ___ >> >>> ___ >> >>> >> >>> >> >>> >> >>> Thank you. >> >>> >> >>> >> >>> >> >>> >> >>> >> >>> >> ------------------------------------------------------------------------------ >> >>> Site24x7 APM Insight: Get Deep Visibility into Application Performance >> >>> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month >> >>> Monitor end-to-end web transactions and take corrective actions now >> >>> Troubleshoot faster and improve end-user experience. Signup Now! >> >>> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 >> >>> >> >>> >> >>> >> >>> _______________________________________________ >> >>> Asterisk-java-devel mailing list >> >>> Ast...@li... >> >>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel >> >> >> >> >> > >> > >> > >> ------------------------------------------------------------------------------ >> > Site24x7 APM Insight: Get Deep Visibility into Application Performance >> > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month >> > Monitor end-to-end web transactions and take corrective actions now >> > Troubleshoot faster and improve end-user experience. Signup Now! >> > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 >> > _______________________________________________ >> > Asterisk-java-devel mailing list >> > Ast...@li... >> > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel >> > >> >> >> ------------------------------------------------------------------------------ >> Site24x7 APM Insight: Get Deep Visibility into Application Performance >> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month >> Monitor end-to-end web transactions and take corrective actions now >> Troubleshoot faster and improve end-user experience. Signup Now!http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 >> >> >> >> _______________________________________________ >> Asterisk-java-devel mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel >> >> >> >> >> ------------------------------------------------------------------------------ >> Site24x7 APM Insight: Get Deep Visibility into Application Performance >> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month >> Monitor end-to-end web transactions and take corrective actions now >> Troubleshoot faster and improve end-user experience. Signup Now! >> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 >> _______________________________________________ >> Asterisk-java-devel mailing list >> Ast...@li... >> https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel >> >> > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now!http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > > > > _______________________________________________ > Asterisk-java-devel mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > > > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > > |