本文介绍了在哪里关闭Elasticsearch客户端连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我应该在哪里关闭与Elasticsearch的客户端的连接?我正在使用Spring,我不想使用Elasticsearch集成,因为我想先学习如何去做。是否应该只为该应用程序创建一个客户端?这意味着它将具有单一范围?或者它应该具有原型范围并关闭每次交互的连接吗?
Where should I close the connection to a client for Elasticsearch? I am using Spring, and I don't want to use the Elasticsearch integration because I want to learn how to do it without first. Should only one client be created for the application? Meaning that it would have singleton scope? Or should it have prototype scope and close the connection for each interaction?
推荐答案
您应该为每个应用程序使用一个客户端,使其成为单例并在应用程序关闭时关闭。
You should use one client per application, make it a singleton and close on application shutdown.
这篇关于在哪里关闭Elasticsearch客户端连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!