java - Spring PollableChannel - 无法将loggingEnabled设置为false?

标签 java spring spring-integration

我编写了以下配置:

@Slf4j
@Configuration
@EnableConfigurationProperties(BatchProperties.class)
public class BatchConfiguration {

    @Autowired
    private BatchProperties properties;

    @Bean
    public PollableAmqpChannel testingChannel(final RabbitTemplate rabbitTemplate) {
        final PollableAmqpChannel channel = new PollableAmqpChannel(properties.getQueue(), rabbitTemplate);
        channel.setLoggingEnabled(false);
        return channel;
    }

    @Bean
    @ServiceActivator(inputChannel = "testingChannel", poller = @Poller(fixedRate = "1000", maxMessagesPerPoll = "1"))
    public MessageHandler messageHandler(final RabbitTemplate rabbitTemplate) {
        return message -> {
            log.info("Received: {}", message);
            rabbitTemplate.convertAndSend(properties.getQueue(), message);
        };
    }
}

消息已成功读取并重新排队,但我不断收到以下消息:

Calling receive with a timeout value on PollableAmqpChannel. The timeout will be ignored since no receive timeout is supported.

我正在使用 Spring Boot 1.5.3.RELASE。

我已经在以下位置设置了断点:

@Override
public void setLoggingEnabled(boolean loggingEnabled) {
    this.loggingEnabled = loggingEnabled;
}

AbstractAmqpChannel类中。它被调用为“false”(因为它应该根据我的配置),然后每次轮询消息时都会再次调用它并将其设置为“true”。

我检查了哈希码,它似乎是我的 bean,但每条消息的“loggingEnabled”都会重置为“true”。

我的配置有问题吗?我该如何解决这个问题?

最佳答案

它看起来像是一个错误 - 如果你有 spring-integration-jmx在类路径上,或指定 @EnableIntegrationManagement在您的配置类之一上; IntegrationManagementConfigurer bean 将所有启用的日志记录设置为 true IntegrationManagement实现,覆盖您的设置。

请打开JIRA Issue .

同时,您可以添加一个实现 SmartLifecyle 的 bean将标志设置回 false(在 start() 方法中);它将在 IntegrationManagementConfigurer 之后运行.

当然,您也可以设置日志类别org.springframework.integration.amqp.channel.PollableAmqpChannelWARN实现同样的效果要简单得多。

关于java - Spring PollableChannel - 无法将loggingEnabled设置为false?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45772527/

相关文章:

java - 如何通过 spring 集成来管道化 amqp 队列?

java - 使用 XA 事务时通过 Spring Integration 和 WebSphere 有效利用消费者

Java 类引用

java - IntelliJ IDEA 调试器在停止时不会终止进程

java - Spring Batch 在处理每个批处理后是否释放堆内存?

java - Spring Security 多个成功和失败处理程序不能很好地工作

java - Spring Integration 的实际用例?

java - 动态 jackson 场过滤

java - 无法添加时间戳

在 Spring Integration 中模拟 MessageHandler 时出现 java.lang.NoSuchMethodError