如何检查Spring Boot应用与Filenet的连接是否成功?
如何为Spring Boot应用实现Filenet连接健康检查?
我的Spring Boot应用通过Filenet Java SDK连接Filenet的功能正常,现在需要实现健康指示器来定期检查连接状态,核心问题是:如何可靠地验证与Filenet的连接是否成功?
已尝试的方案
- 创建连接并获取ObjectStore:该操作始终返回成功,不会抛出任何错误,无法有效判断连接是否真的可用
Connection conn = com.filenet.api.core.Factory.Connection.getConnection("https://..."); Subject subject = UserContext.createSubject(conn, "User", "password", "jaasStanzaName"); UserContext uc = UserContext.get(); uc.pushSubject(subject); ObjectStore os = Factory.ObjectStore.getInstance(Factory.Domain.getInstance(conn, null), "objectStoreName");
- 执行SQL查询:该操作会在连接异常时抛出
EngineRuntimeException,但我认为依赖异常处理来做健康检查属于不良代码实践
// 复用上述连接 SearchSQL sqlObject = new SearchSQL("SELECT * FROM ..."); SearchScope searchScope = new SearchScope(conn.getObjectStore()); IndependentObjectSet results = searchScope.fetchObjects(sqlObject, null, filter, true);
想请教是否有更合适的成熟方法或最佳实践可以采用?
内容的提问来源于stack exchange,提问作者Puck
相关产品推荐
相关产品推荐

