committed to r1476219 an amended patch following a suggestion from Robbie Gemmell that avoided iterating through connections by getting the AMQConnectionModel from the AMQSessionModel in the getSessionAdapter() helper e.g.
/**
- Helper method to retrieve the SessionAdapter keyed by the AMQSessionModel.
- This method first finds the ConnectionAdapter associated with the Session from this QueueAdapter's parent vhost
- then it does a lookup on that to find the SessionAdapter keyed by the requested AMQSessionModel instance.
- @param session the AMQSessionModel used to index the SessionAdapter.
- @return the requested SessionAdapter or null if it can't be found.
*/
private SessionAdapter getSessionAdapter(AMQSessionModel session)
{
// Retrieve the ConnectionModel associated with the SessionModel as a key to lookup the ConnectionAdapter.
AMQConnectionModel connectionKey = session.getConnectionModel();
// Lookup the ConnectionAdapter, from which we should be able to retrieve the SessionAdapter we really want.
ConnectionAdapter connectionAdapter = _vhost.getConnectionAdapter(connectionKey);
if (connectionAdapter == null)
{
return null; // If we can't find an associated ConnectionAdapter the SessionAdapter is a lost cause.
}
else
{ // With a good ConnectionAdapter we can finally try to find the SessionAdapter we are actually looking for.
SessionAdapter sessionAdapter = connectionAdapter.getSessionAdapter(session);
if (sessionAdapter == null)
{
return null; // If the SessionAdapter isn't associated with the selected ConnectionAdapter give up.
}
else
{
return sessionAdapter;
}
}
}
The changes to the Java broker only were merged to the 0.22 release branch via: http://svn.apache.org/r1477558
(the QMF2 agent not being on the 0.22 release branch)