@Test public void testPause() throws InterruptedException { Connection connection = createConnectionWithQueue(1000, 2, 1); AtomicInteger count = createSomeMessyQueues(connection); Thread.sleep(55L); connection.pause(); int countRightAfterPause = count.get(); System.out.println(countRightAfterPause); Thread.sleep(100L); System.out.println(count.get()); int countNow = count.get(); Assert.assertTrue("Messages should be drained from the queue", countNow > countRightAfterPause); Thread.sleep(100L); Assert.assertEquals("Messages should stopped being consumed as the queue is paused now", countNow, count.get()); Assert.assertTrue(countNow > 0 && countNow < 10000); }
@Override public void pause() { queues.values().forEach(Queue::pause); }
PersistentMessagingServer implements Connection { @Override public void pause() { queues.values().forEach(Queue::pause); } }
PersistentMessagingServer implements Connection { @Override public void pause() { queues.values().forEach(Queue::pause); } PersistentMessagingServer(MessagePersister persister); }
PersistentMessagingServer implements Connection { @Override public void pause() { queues.values().forEach(Queue::pause); } PersistentMessagingServer(MessagePersister persister); @Override void createQueue(
            String queueName,
            int memoryBufferMaxMessages,
            int secondsToSleepBetweenMessageRetries,
            int maxRetries); @Override void sendMessage(String queueName, InputStream messageBody, Map<String, String> headers); @Override void sendMessage(String queueName, Consumer<OutputStream> writer, Map<String, String> headers); @Override void subscribe(String queueName, String consumerName, Consumer<Message> messageConsumer); @Override void unsubscribe(String queueName, String consumerName); @Override void pause(); @Override void pause(String queueName); @Override void start(); @Override void start(String queueName); }
PersistentMessagingServer implements Connection { @Override public void pause() { queues.values().forEach(Queue::pause); } PersistentMessagingServer(MessagePersister persister); @Override void createQueue(
            String queueName,
            int memoryBufferMaxMessages,
            int secondsToSleepBetweenMessageRetries,
            int maxRetries); @Override void sendMessage(String queueName, InputStream messageBody, Map<String, String> headers); @Override void sendMessage(String queueName, Consumer<OutputStream> writer, Map<String, String> headers); @Override void subscribe(String queueName, String consumerName, Consumer<Message> messageConsumer); @Override void unsubscribe(String queueName, String consumerName); @Override void pause(); @Override void pause(String queueName); @Override void start(); @Override void start(String queueName);  }