session.commit();
      public void run()      {         try         {            synchronized (semaphore)            {               semaphore.wait();            }            int counter = 0;            while (true)            {               Message message = consumer.receive(50);               if (message==null && shouldStop)               {                  break;               }               if (message!=null)               {                  synchronized (lockReader)                  {                     messageCounterConsumer++;                  }                  log.trace("ReceiverID=" + id + " received message " + message);                  if (counter++ % 10 == 0)                  {                     //log.info("Commit on id=" + id);                     session.commit();                  }               }            }            session.commit();         }         catch (Exception e)         {            log.info("Caught exception... finishing Thread " + id, e);         }      }