Spring mongo queries set custom timeout(Spring mongo 查询设置自定义超时)
问题描述
我想降低 spring-mongo java 应用程序中的超时设置(如果无法访问数据库,查询应该在 300 毫秒后失败).
I would like to lower the timeout setting in my spring-mongo java application (the query should fail after 300 ms if the database is not accessible).
我试过这个配置:
但是 mongoUri 选项和构建器都会更改超时:查询仅在 30 000 毫秒后失败.
But the mongoUri options nor the builder change the timeout: the query fails only after 30 000ms.
我不确定应该覆盖哪个参数,也不确定如何正确执行.
I am not sure which parameter I should override nor the way to do it properly.
感谢您的帮助
推荐答案
我在这里找到了答案:https://scalegrid.io/blog/understanding-mongodb-client-timeout-options/
这篇关于Spring mongo 查询设置自定义超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!