Spring 集成泄漏

问题描述 投票:0回答:1

我有一个 Spring 集成应用程序。它基本上有一个带有 requestChannel 的网关,以及一个从通道消费的

@ServiceActivator
@ServiceActivator
使用轮询器从通道中获取新消息。

@ServiceActivator(inputChannel = "inputChannel", poller = @Poller(fixedDelay = "10", maxMessagesPerPoll = "50", taskExecutor = "myExecutor"))

<task:executor id="myExecutor" pool-size="1" rejection-policy="DISCARD"/>

当我运行该应用程序时,我看到很多

java.util.concurrent.LinkedBlockingQueue$Node
org.springframework.integration.util.ErrorHandlingTaskExecutor$$Lambda
org.springframework.integration.endpoint.AbstractPollingEndpoint$$Lambda
正在创建但从未释放。

enter image description here

事实上,我已经看到这些对象的创建不需要在队列中添加新消息,所以看起来轮询器创建了所有这些对象。我可以确认这一点,因为当我禁用

@ServiceActivator
时,不会创建这些对象。

有人可以建议如何摆脱这些物体吗?

提前致谢!

spring memory-leaks spring-integration resource-leak
1个回答
0
投票

该行为是预期的。

QueueChannel
没有订阅者。相反,它会定期轮询。 这是通过提到的
poller
配置和
TaskScheduler
内部完成的。由于该轮询器不知道消息是否已被生产者排队,因此无法控制其行为。无论如何,必须安排轮询任务:队列中没有消息 - 好的,放弃并继续。

问题确实在这里:

fixedDelay = "10"
。这意味着在前一个轮询结束 10 毫秒后开始新的轮询。

因此,请考虑将其调整为更有意义且压力更小的事情。

    

© www.soinside.com 2019 - 2024. All rights reserved.