    @Test
    public void test_messages_are_enqueued_to_redis() throws InterruptedException {


        LOGGER.debug("creating the logger");
        Logger logger = LOGGER_CONTEXT_RESOURCE
                .getLoggerContext()
                .getLogger(RedisAppenderTest.class.getCanonicalName());

        int expectedMessageCount = MIN_MESSAGE_COUNT + RANDOM.nextInt(MAX_MESSAGE_COUNT - MIN_MESSAGE_COUNT);
        LOGGER.debug("logging %d messages", expectedMessageCount);
        LogMessage[] expectedLogMessages = LogMessage.createRandomArray(expectedMessageCount);
        for (LogMessage expectedLogMessage : expectedLogMessages) {
            logger.log(expectedLogMessage.level, expectedLogMessage.message);
        }

        LOGGER.debug("waiting for throttler to kick in");
        Thread.sleep(1_000);

        LOGGER.debug("checking logged messages");
        Jedis redisClient = REDIS_CLIENT_RESOURCE.getClient();
        for (int messageIndex = 0; messageIndex < expectedMessageCount; messageIndex++) {
            LogMessage expectedLogMessage = expectedLogMessages[messageIndex];
            String expectedSerializedMessage = String.format(
                    "%s %s",
                    expectedLogMessage.level,
                    expectedLogMessage.message);
            String actualSerializedMessage = redisClient.lpop(RedisAppenderTestConfig.REDIS_KEY);
            try {
                assertThat(actualSerializedMessage).isEqualTo(expectedSerializedMessage);
            } catch (ComparisonFailure comparisonFailure) {
                String message = String.format(
                        "comparison failure (messageIndex=%d, messageCount=%d)",
                        messageIndex,
                        expectedMessageCount);
                throw new RuntimeException(message, comparisonFailure);
            }
        }

        Appender appender = LOGGER_CONTEXT_RESOURCE
                .getLoggerContext()
                .getConfiguration()
                .getAppender(RedisAppenderTestConfig.LOG4J2_APPENDER_NAME);
        assertThat(appender).isInstanceOf(RedisAppender.class);
        RedisThrottlerJmxBean jmxBean = ((RedisAppender) appender).getJmxBean();
        assertThat(jmxBean.getTotalEventCount()).isEqualTo(expectedMessageCount);
        assertThat(jmxBean.getIgnoredEventCount()).isEqualTo(0);
        assertThat(jmxBean.getEventRateLimitFailureCount()).isEqualTo(0);
        assertThat(jmxBean.getByteRateLimitFailureCount()).isEqualTo(0);
        assertThat(jmxBean.getUnavailableBufferSpaceFailureCount()).isEqualTo(0);
        assertThat(jmxBean.getRedisPushSuccessCount()).isEqualTo(expectedMessageCount);
        assertThat(jmxBean.getRedisPushFailureCount()).isEqualTo(0);

    }