log.debug("terminating sending because message count has been reached");
log.debug("terminating sending because message count (" + messageCount + ") has been reached");
      public void run()      {         // if both duration and message count are set, the job sends until the first condition         // is met         try         {            log.debug("start sending using " + fullDump());            long start = System.currentTimeMillis();            long timeLeft;            while (true)            {               timeLeft = duration - System.currentTimeMillis() + start;               if (timeLeft <= 0)               {                  log.debug("terminating sending because time (" + duration + " ms) expired");                  break;               }               Message m = messageFactory.getMessage(sess, messageSize);                              if (anon)               {                  prod.send(destination, m);               }               else               {                  prod.send(m);               }               currentMessageCount++;               if (log.isTraceEnabled()) { log.trace("sent message " + currentMessageCount); }                              if (transacted)               {                                    if (currentMessageCount % transactionSize == 0)                  {                     sess.commit();                     if (log.isTraceEnabled()) { log.trace("committed"); }                  }               }                 if (currentMessageCount == messageCount)               {                  // message count exit condition                  if (transacted)                  {                     sess.commit();                     if (log.isTraceEnabled()) { log.trace("committed"); }                  }                  log.debug("terminating sending because message count has been reached");                  break;               }                              doThrottle();                                         }                                                 actualTime = System.currentTimeMillis() - start;                        log.info("sent " + currentMessageCount + " messages, actual duration is " + actualTime + " ms");         }         catch (Throwable e)         {            log.error("Sender failed", e);            failed = true;         }         finally         {            log.info("finished sending on " + destination);         }      }