Java 黄瓜试验中的语境封闭问题

Java 黄瓜试验中的语境封闭问题,java,apache-camel,cucumber,Java,Apache Camel,Cucumber,问题 问题有点小,但如下所示: 当Cucumber测试中存在多个场景时,日志会被以下消息污染: 14:54:54.021 [Camel (camel-1) thread #7 - TemporaryQueueReplyManager[queueName]] ERROR o.a.c.c.j.DefaultJmsMessageListenerContainer - Could not refresh JMS Connection for destination 'temporary' - retry

问题

问题有点小,但如下所示: 当Cucumber测试中存在多个场景时,日志会被以下消息污染:

14:54:54.021 [Camel (camel-1) thread #7 - TemporaryQueueReplyManager[queueName]] ERROR o.a.c.c.j.DefaultJmsMessageListenerContainer - Could not refresh JMS Connection for destination 'temporary' - retrying using FixedBackOff{interval=5000, currentAttempts=26, maxAttempts=unlimited}. Cause: null
我在做什么

所以我有一个应用程序,它产生一个胖罐子。在Cucumber测试中,我从自己的工作目录为每个场景运行这个jar。jar使用JMS,因此我在测试中创建了一个ActiveMQ代理来进行通信。虽然jar没有使用apachecamel,但是Cucumber测试确实使用Camel

在每个场景开始时,安装jar,构建Camel上下文,启动AMQ代理,最后启动jar

然后进行测试步骤,在jar拥有主动权的情况下使用路由,在我正在存根的应用程序拥有主动权的情况下使用生产者

在测试结束时,我首先停止应用程序,在CamelContext上调用stop并停止代理

这种模式似乎是,对于相同功能文件中的每个场景(位于相同的JUnit运行定义下),上述错误的出现次数似乎在增加

我的假设是,上下文中的某个东西是挥之不去的,这导致了信息

我尝试过的

在项目开始时,选择了Camel版本2.19.5。我试着用2.24.3版运行它,它没有改变任何东西

我其余的尝试都在这个块中,在这里我停止CamelContext和broker:

    camelContext.getShutdownStrategy().setSuppressLoggingOnTimeout(true);
    camelContext.getShutdownStrategy().setLogInflightExchangesOnTimeout(false);
    camelContext.getShutdownStrategy().setTimeout(TimeUnit.SECONDS.toMillis(5));
    camelContext.stop();
    long startTime = System.currentTimeMillis();
    try {
        Awaitility.await().atMost(1, TimeUnit.MINUTES).until(() -> camelContext.getRoutes().isEmpty());
    } finally {
        LOG.info("Waited time for Camel was {}", System.currentTimeMillis() - startTime);
        startTime = System.currentTimeMillis();
        if (broker != null) {
            broker.getBrokerService().stop();
            broker.getBrokerService().waitUntilStopped();
            LOG.info("Waited time for ActiveMQ was {}", System.currentTimeMillis() - startTime);
        }
    }
Camel的日志记录时间约为100ms,ActiveMQ的日志记录时间不到10ms