Camel Producer模板可能存在内存泄漏

时间:2014-10-17 18:15:58

标签: apache-camel

在某种程度上,这在黑暗中是一个镜头,但我们有一个过程在一天中显着减慢。我们发现在Fuse上运行的所有内容都开始拖动,但只有在我们运行特定进程时才会发生。运行JProfiler,我发现org.apache.camel.ProducreTemplate.send上标记的内存使用量会随着时间的推移而增加。

所以我的主要问题是,我在这里使用ProducerTemplate的方式是否存在错误/可能导致此问题?

Exchange foo = new DefaultExchange(getCamelContext(), ExchangePattern.InOnly);
foo.getIn().setBody(obj);
Route r = exchange.getContext().getRoute("do_something_fun");
ProducerTemplate template = exchange.getContext().createProducerTemplate();
template.send(r.getEndpoint(), foo);

1 个答案:

答案 0 :(得分:2)

通常,您不应对每个请求创建ProducerTemplate,如下所述:http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html

但是,因为我没有完整的应用程序图片,所以你可能会遇到无法重复使用它的情况,但是当你完成它时你必须记得关闭它。

相关问题