docs: private int lockMessages(boolean isolatedRun) throws SIResourceException
      {
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
              SibTr.entry(tc, "lockMessages", new Object[] { this, Boolean.valueOf(isolatedRun) });
  
          int numOfMsgs = 0;
  
          _transferredConsumer = null;
          if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
              SibTr.debug(tc, "GatherMessages: " + Boolean.valueOf(_gatherMessages)
                              + ", instance isolatedRun: " + Boolean.valueOf(_isolatedRun)
                              + ", _hasLocalQP: " + Boolean.valueOf(_hasLocalQP));
          // If we're doing an isolated run then we don't want to become ready
          // but we do still want to drain the queue. Unfortunately, if we're remote
          // from the queue we probably won't have a message sat there waiting and
          // therefore we do need to make ourselves ready and issue a request back
          // to the DME. (unless we are gathering in which case we have to treat 
          // the consumer as if it is local)
          if (!isolatedRun || (!_hasLocalQP || _gatherMessages))
          {
              // If the LCP is stopped then do nothing (unless we're an isolated run)
              if (_stopped && !isolatedRun)
              {
                  //we're not ready for more messages
                  unsetReady();
                  //don't try and get any more
                  _drainQueue = false;
              }
              else
              {
                  // we are ready for new messages, before we look for one on the ItemStream
                  // we tell teh COnsumerDispatcher that we're available for messages just to
                  // make sure we don't miss one coming in while we're looking on the ItemStream
                  // (and not finding any). If we do find a suitable message on the ItemStream
                  // we mark ourselves as unready. This obviously introduces the possibility of
                  // the ConsumerDispatcher trying to give us a message, but better a false
                  // possitive than a message falling down the gap.
                  try
                  {
                      setReady();
                  } catch (SINotPossibleInCurrentConfigurationException e)
                  {
                      // No FFDC code needed
                      //don't try and get any more
                      _drainQueue = false;
                  }
              }
  
              // Remember we're in the middle of an isolated run (so that put() knows
              // what to do)
              if (isolatedRun)
                  _isolatedRun = isolatedRun;
              if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                  SibTr.debug(tc, "Instance isolatedRun: " + Boolean.valueOf(_isolatedRun));
          }
  
          if ((_keyGroup != null) && !_keyGroup.isStarted())
              _drainQueue = false;
  
          boolean consumerReady = true;
  
          // If the consumer has asked for batches of messages we'll look for that number
          // of available messages on the queue and give them to the asynch consumer all in
          // one go. If this is a stoppable consumer we'd like to keep the number of messages
          // being processed within the number of possible hidden messages (which equals the
          // maxSequentialFailuresThreshold). So we crop the batch size to the remaining
          // space we have left for hidden messages (or one) whichever is the larger.
          // However, that would limit the batch size when there are no problems which is a little
          // rough so we only do the cropping once we've started hiding messages (which can result
          // in a few more messages being processed/hidden to start with but that's life). 
          int currentMaxBatchSize = _maxBatchSize;
          if (_consumerStoppable && (currentMaxBatchSize > 1) && (_hiddenMessages.size() > 0))
          {
              int remainingHiddenSpace = _maxSequentialFailuresThreshold - _hiddenMessages.size();
              if (remainingHiddenSpace < 1)
                  remainingHiddenSpace = 1;
              if (remainingHiddenSpace < currentMaxBatchSize)
                  currentMaxBatchSize = remainingHiddenSpace;
  
              if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                  SibTr.debug(tc, "lockMessages", "Cropped maxBatchSize to " + currentMaxBatchSize);
          }
  
          //while we still want more messages
          while ((numOfMsgs < currentMaxBatchSize) && // filled the batch
                 _drainQueue && // emptied the queue
                 (!_lockRequested || (numOfMsgs == 0)) && // Asked to interupt
                 (!_interruptConsumer || (numOfMsgs == 0)) && // Interrupted (ignore first time round)
                 (_transferredConsumer == null)) // switched ordered consumer
          {
              SIMPMessage msg = null;
  
              if (_keyGroup != null)
              {
                  // If we are part of a group, we want to remember which member of the group actually gets matched
                  // when the filter is called.
                  _keyGroup.setConsumerActive(true);
              }
  
              //try and get a locked eligible message
              msg = getEligibleMsgLocked(null);
  
              if (msg != null)
              {
                  JSLocalConsumerPoint matchingConsumer = this;
  
                  // We've found a message that matches. If we are a member of
                  // an ordering group it is possible that this message matches
                  // a different member of the group from us. If that is that is
                  // the case we have to possibilities....
                  // i) If this is the fist message in the batch we can pass the locked
                  // message to the matching consumer for them to process.
                  // ii) If we already have messages in our batch we will have to
                  // unlock this message and process the batch first.
                  if (_keyGroup != null)
                  {
                      // find out which member of the group actually got matched
                      matchingConsumer = (JSLocalConsumerPoint) _keyGroup.getMatchingMember(_consumerKey).getConsumerPoint();
                      // and show that we're done with the filter for now
                      _keyGroup.setConsumerActive(false);
                  }
  
                  // The message is intended for this consumer
                  if (matchingConsumer == this)
                  {
                      // If we've got a message then we're no longer interested
                      // in messages straight from the ConsumerDispatcher but if
                      // looking for a batch of messages we may take a long time
                      // to exit this loop, so take ourselves out of the runnin
                      // as soon as possible.
                      if (consumerReady)
                      {
                          consumerReady = false;
                          unsetReady();
                      }
  
                      // Do we really need this message in the MS?
                      boolean isRecoverable = true;
                      if ((_unrecoverableOptions != Reliability.NONE) &&
                          (msg.getReliability().compareTo(_unrecoverableOptions) <= 0))
                          isRecoverable = false;
  
                      registerForEvents(msg);
  
                      //store a reference to the locked message in the LME
                      _allLockedMessages.addNewMessage(msg, true, isRecoverable);
  
                      //If we were successful, increment our counter
                      numOfMsgs++;
  
                      // We check for an interupt after every message is locked
                      if (_externalConsumerLock != null)
                          _interruptConsumer = _externalConsumerLock.isLockYieldRequested();
                  }
                  // The message is intended for another member of the key group
                  else
                  {
                      // If we already have messages locked to this consumer we must
                      // unlock the last message and process the others first. Then
                      // we can come back and pick this one up later (if it is still
                      // available)
                      if (numOfMsgs > 0)
                      {
                          try
                          {
                              msg.unlockMsg(msg.getLockID(), null, true);
                              msg = null;
                          } catch (MessageStoreException e)
                          {
                              // MessageStoreException shouldn't occur so FFDC.
                              FFDCFilter.processException(
                                                          e,
                                                          "com.ibm.ws.sib.processor.impl.JSLocalConsumerPoint.lockMessages",
                                                          "1:2995:1.22.5.1",
                                                          this);
  
                              SibTr.exception(tc, e);
  
                              if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                                  SibTr.exit(tc, "lockMessages", e);
  
                              throw new SIResourceException(
                                              nls.getFormattedMessage(
                                                                      "INTERNAL_MESSAGING_ERROR_CWSIP0002",
                                                                      new Object[] {
                                                                                    "com.ibm.ws.sib.processor.impl.JSLocalConsumerPoint",
                                                                                    "1:3008:1.22.5.1",
                                                                                    e },
                                                                      null),
                                              e);
                          }
                      }
                      // This is the only message locked so we can just drive the
                      // correct consumer
                      else
                      {
                          numOfMsgs++;
  
                          // Mark the fact that we've transferred ownership of a locked message
                          // so that it can be processed by the calling method (outside of any
                          // LCP locks)
                          _transferredConsumer = matchingConsumer;
  
                          _transferredConsumer.lock();
                          try
                          {
                              _transferredConsumer.unsetReady();
                              _transferredConsumer.addLockedMessage(msg);
                          } finally
                          {
                              _transferredConsumer.unlock();
                          }
  
                          // We now want to drop out of the loop so we can process this message
                          // with the correct consumer
  
                          // We check for an interupt after every message is locked
                          if (_externalConsumerLock != null)
                              _interruptConsumer = _externalConsumerLock.isLockYieldRequested();
                      }
                  }
              }
              if (msg == null)
              {
                  // We have all the messages currently on the
                  // queue so we are about to callack to
                  // get them processed.
  
                  //stop trying to get any more
                  _drainQueue = false;
              }
  
              // We check for an interupt after every message is locked
              if (_externalConsumerLock != null)
                  _interruptConsumer = _externalConsumerLock.isLockYieldRequested();
          } // end while
  
          // If we're an isolated run and we found a message (i.e. not ready) then
          // no-one will try to deliver a message to us and therefore we can forget
          // that we were ever here. On the other hand, if we couldn't find a message
          // and the queue is remote we need to signal that we're still waiting.
          if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
              SibTr.debug(tc, "Instance isolatedRun: " + Boolean.valueOf(_isolatedRun) +
                              ", method isolatedRun: " + Boolean.valueOf(isolatedRun) +
                              ", ready: " + Boolean.valueOf(_ready));
          if (isolatedRun && !_ready)
              _isolatedRun = false;
  
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
              SibTr.exit(tc, "lockMessages", Integer.valueOf(numOfMsgs));
  
          return numOfMsgs;
      }