我编写了以下配置:
@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.PollableAmqpChannel
至WARN
实现同样的效果要简单得多。
关于java - Spring PollableChannel - 无法将loggingEnabled设置为false?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45772527/