Re: [Asterisk-java-devel] ChannelManager Sync
Brought to you by:
srt
|
From: Martin B. S. <ma...@mb...> - 2009-07-10 00:15:25
|
Michael Yara wrote:
> Hello,
>
> We are currently running in a distributed Asterisk environment with
> Asterisk servers both local and remote to the application that is
> utilizing Asterisk-Java. We are consolidating events using AstManProxy
> and everything has worked quite nicely except for one small issue. There
> are some points when the proxy losses the connection to a remote server
> and in turn we miss events concerning channel hangups and creation.
> Basically we want to be able to run a command on our application that
> will re-sync the Channel Manager state utilizing a call to Status
> Action. Re-creating the AsteriskServer object is not an option. My plan
> was to modify the Asterisk-Java code to expose the channel manager and
> feed the StatsEvents to the Channel Manager to implement any channels
> that were not created due to missing the newChannel events and at the
> same time providing a remove channel method that will remove a channel
> from the channel map in the Channel Manager. My question is can my idea
> work properly without mucking up the ChannelManager or is there possibly
> a better way to re initialize the ChannelManager while keeping the
> existing AsteriskChannel objects in my model valid. I apologize if this
> is the wrong list to be asking this question.
>
Hi Michael,
This is probably a good venue for your question. I think Stefan and I
may have even discussed the choice, at some point, of exposing the
channel manager directly. However, I think that, at least in my context,
I ended up not needing to expose the channel manager to solve my problem
-- resyncing channels.
I believe, in my case, I simply fed the state events to the
asteriskServer by directly calling onNew... with my own event objects.
My resync looked something like this:
Collection<AsteriskChannel> channels = asteriskServer.getChannels();
for(AsteriskChannel channel : channels) {
onNewAsteriskChannel(channel);
if(channel.getLinkedChannel() != null) {
AsteriskChannel linkedChannel = channel.getLinkedChannel();
PropertyChangeEvent propertyChangeEvent = new
PropertyChangeEvent(channel, AsteriskChannel.PROPERTY_LINKED_CHANNEL,
null, linkedChannel);
propertyChange(propertyChangeEvent);
}
}
Does that work for you? I want to say there's some code floating around
in the implementation of the DefaultAsteriskServer that does something
similar...
Cheers,
Martin
|