code: public void messagesAdded(int msgCount, BatchListener listener) throws SIResourceException
    {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        SibTr.entry(this, tc, "messagesAdded","msgCount="+msgCount+",listener="+listener);
  
      boolean completeBatch = false;
  
      try
      {
        synchronized(this) // lock the state against other readers
        {
          _currentBatchSize += msgCount;
  
          if((listener != null) && (!_listeners.contains(listener)))
          {
            // Remember that this listener needs calling when the batch completes
            _listeners.add(listener);
          }
  
          if(_currentBatchSize >= _batchSize) // Full batch, commit all updates
          {
            completeBatch = true;  // We can't do this under the synchronize as the exclusive lock
                                   // we need will deadlock with reader's trying to get this
          }                        // synchronize before these release their shared lock
          else if ((_currentBatchSize - msgCount) == 0) // New batch so ensure a timer is running
          {
            startTimer();
          }
        }
      }
      finally
      {
        _readWriteLock.unlock(); // release the read lock we took in registerInBatch
      }
  
      // Now we hold no locks we can try to complete he batch (this takes an exclusive lock
      if(completeBatch)
      {
        completeBatch(false);   // false = only complete a full batch
      }
  
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        SibTr.exit(this, tc, "messagesAdded");
    }
docs: Tell the BatchHandler how many messages were added under the current
  transaction.
  
  registerInBatch must have been called first to register
  the users interest in the current batch and to get hold of the current
  transaction. After this method returns, if there are no remaining interested
  users, the BatchHandler is free to commit the transaction.
  
  An optional listener may be provided to receive notification of transactional
  events.
  
  @param msgCount The number of messages added, must be 0 or greater
  @param listener An optional listener, may be null