if (response == null) break;
  private void processHeartbeats() {   synchronized (lock) {    long minFreq = Long.MAX_VALUE;  // milliseconds until next heartbeat should be sent    Iterator iter = sub.getCollection().iterator();    while (iter.hasNext()) {      HbReq req = (HbReq)iter.next();      if (log.isDebugEnabled())         log.debug("\nHeartbeatServerPlugin.processHeartbeats: processing HbReq = " + req);      HbReqContent content = (HbReqContent)req.getContent();      HbReqResponse response = (HbReqResponse)req.getResponse();      long now = System.currentTimeMillis();      long lastHbSent = response.getLastHbSent();      long freq = content.getHbFrequency();      // ignore new requests here - execute will handle      if (lastHbSent != -1) {        // check if its time to send a heartbeat or not for this one        long start = response.getFirstHbSent();         long lastHbDue = start + ((now - start)/freq)*freq;        long nextHbDueFromNow = lastHbDue + freq - now;        if (minFreq > nextHbDueFromNow) minFreq = nextHbDueFromNow;        if (lastHbDue > lastHbSent) {   // its time for this one          MessageAddress me = getBindingSite().getAgentIdentifier();          response.setResponder(me);          response.setStatus(HbReqResponse.HEARTBEAT);          response.setLastHbSent(now);          req.updateResponse(me, response);          bb.publishChange(req);          if (log.isDebugEnabled())             log.debug("\nHeartbeatServerPlugin.processHeartbeats: published changed HbReq = " + req);        }      }    }    if (minFreq != Long.MAX_VALUE) {      if (nextAlarm != null) nextAlarm.cancel();      nextAlarm =  new ProcessHeartbeatsAlarm(minFreq);      alarmService.addRealTimeAlarm(nextAlarm);    }   }  } 