1 2 Previous Next 23 Replies Latest reply on Oct 8, 2009 4:39 PM by timfox

    HORNETQ-82 :: Allow delivery to be paused/resumed on queues

      Hi guys, I'm sending my proposal for getting this enhancement done, feel free to tell me what you think but remember that this is my first contribution to the project so I'm certanly missing something ;)

      1. Add the methods pause(), isPaused() and resume() to the Queue interface
      2. Add an AtomicBoolean called paused to the QueueImpl class
      3. Implement the pause() , isPaused() and resume() methods of QueueImpl with something like this

      public void pause()
      {
      if(paused.get()){
      log.warn("Pausing an already paused queue.");
      return;
      }
      paused.set(true);
      }

      public void resume()
      {
      if(!paused.get()) {
      log.warn("Trying to resume a non-paused queue.");
      return;
      }
      paused.set(false);
      deliver();
      }

      public boolean isPaused()
      {
      return paused.get();
      }

      4. Modify the deliver() private method to add the following check at the beginning:

      if(paused.get()){
      log.error("queue is paused!");
      return;
      }

      5. Add the same three method to the QueueControl interface. Add an @Operation annotation to each of them too.
      6. Implement those three methods in the QueueControlImpl class with something like this:

      public void pause()
      {
      this.queue.pause();
      }

      public void resume()
      {
      this.queue.resume();
      }

      public boolean isPaused()
      {
      return queue.isPaused();
      }

      7. Add the following test to the QueueImplTest and QueueControlTest classes:

      testPauseAndResume();

      The first will assert that the message aren't delivered when the Queue is paused and the second is pretty obvious.

      Diego
      PlugTree.com

        1 2 Previous Next