public synchronized void purge ( short sessionId ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "purge" , "" + sessionId ) ; // We have to travese the queue and look at all the entries for this int [ ] indexsToDelete = new int [ queue . size ( ) ] ; int indexCount = 0 ; boolean completeBatchRemoved = false ; // First build a list of all the items to delete for ( int x = 0 ; x < queue . size ( ) ; x ++ ) { QueueData data = queue . get ( x ) ; // Get the session id. If it matches the one passed in, remove the message if ( data . getProxyQueue ( ) . getId ( ) == sessionId ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Deleting item: " + data ) ; indexsToDelete [ indexCount ++ ] = x ; completeBatchRemoved = data . isLastInBatch ( ) ; } } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Removing " + indexCount + " entries" ) ; // Now perform the deletes in reverse order for ( int x = ( indexCount - 1 ) ; x >= 0 ; x -- ) { queue . remove ( indexsToDelete [ x ] ) ; } // If we removed a complete batch, decrement the counter if ( completeBatchRemoved ) batchesReady -- ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Purge completed. Queue is now: " + this ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "purge" ) ; }
This method will purge messages from the queue that belong to a particular session Id .