Re: [Asterisk-java-users] DefaultAsteriskManager and queues
Brought to you by:
srt
From: Jan E. <jan...@pl...> - 2005-07-13 06:38:38
|
On Wednesday 13 July 2005 09:18, Stefan Reuter wrote: > Hi Jan, > > > I noticed that DefaultAsteriskManager does handle queues too, or at least > > it has the stubs for it in 0.1. However, as the flag queuesInitialized is > > always true > > DefaultAsteriskManager requests Channel and Queue state at startup. To > do this it sends a StatusAction and a QueueStatusAction. > Until that initial state is received it queues any state changing events > to apply them as delta to the initial state later on. > The StatusAction results in a StatusEvents being sent for every active > channel. Asterisk indicates that all StatusEvents have been sent by > sending a StatusCompleteEvent. So when DefaultAsteriskManager receives a > StatusCompleteEvent it knows that the initial channel state has been > completely received (now channelsInitialized == true). > Unfortunatly the QueueStatusAction does not result in a > QueueStatusComplete event being sent, so it never knows whether queue > state is completely received. Therefore the hack to set it to true at > startup. This will work most of the time, but might cause trouble when > receiving queue changing events while still evaluating the results of > the QueueStatusAction. Doesn't the StatusComplete come before the Queue events event have started to arrive, so thus when they come initialized==true and the events are not handled internally at all but just dispatched to other registered event handlers. That's my interpretation of the 0.1 code. I have a few test queues and I see that the events for the queues get sent and contain proper data. If Asterisk sends out the responses sequentially, ie all Status events before the Queue events are even started on, it might work to reorder the two actions (send QueueStatusAction before StatusAction) or to just send a third dummy action that would act as the "we're done with queues" marker. This may be a naive interpretation of how Asterisk works though... > > then the queues never get handled by DefaultAsteriskManager.handleEvent > > and the events are instead sent to event handlers directly. > > They are handled and with the limititation above it works fine. > > > Of course I can > > do the handling manually, but as the code already seems to be in place in > > DefaultAsteriskManager I'd like to use that code and not build my own > > framework on top of it. So call me lazy. :) > > Another option is to just fix DefaultAsteriskManager where it might be > broken and submit a patch. So you get free maintainance for that part in > the future :) Yup, that's an option too. > > Of course, if DefaultAsteriskManager one day starts to handle the > > events then my own code is left cold in the water. > > No, your code will always work. At least if you registered your event > handler independently with the underlying ManagerConnection. > In this case you always receive every event regardless of what > DefaultAsteriskManager does with that event. Yes, but then when AsteriskManager handles queues internally I end up with the same code duplicated in two places, ie. Asterisk-Java Queue:s and my own Queue:s, both doing basically the same thing but with optionally different names. That I'd rather want to avoid. Regards, Jan Ekholm -- Jan Ekholm jan...@pl... |