private void handleAsyncAgiEvent(AsyncAgiEvent asyncAgiEvent)
{
final ManagerConnection connection;
final String channelName;
final AsyncAgiConnectionHandler connectionHandler;
connection = (ManagerConnection) asyncAgiEvent.getSource();
channelName = asyncAgiEvent.getChannel();
if (asyncAgiEvent.isStart())
{
connectionHandler = new AsyncAgiConnectionHandler(getMappingStrategy(), asyncAgiEvent, this.getAgiChannelFactory());
setConnectionHandler(connection, channelName, connectionHandler);
try
{
execute(connectionHandler);
}
catch (RejectedExecutionException e)
{
logger.warn("Execution was rejected by pool. Try to increase the pool size.");
// release resources if execution was rejected due to the pool size
connectionHandler.release();
}
}
else
{
connectionHandler = getConnectionHandler(connection, channelName);
if (connectionHandler == null)
{
logger.info("No AsyncAgiConnectionHandler registered for channel " + channelName + ": Ignoring AsyncAgiEvent");
return;
}
if (asyncAgiEvent.isExec())
{
connectionHandler.onAsyncAgiExecEvent(asyncAgiEvent);
}
else if (asyncAgiEvent.isEnd())
{
connectionHandler.onAsyncAgiEndEvent(asyncAgiEvent);
removeConnectionHandler(connection, channelName);
}
else
{
logger.warn("Ignored unknown AsyncAgiEvent of sub type '" + asyncAgiEvent.getSubEvent() + "'");