Spring Cloud如何定义Pivotal Cloud Foundry下的验证间隔? [英] How spring cloud defines validation interval under the Pivotal Cloud Foundry?

查看:51
本文介绍了Spring Cloud如何定义Pivotal Cloud Foundry下的验证间隔?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究从PCF(Pivotal Cloud FoundrY)用户提供的服务获取DS的应用程序.它工作正常,但我想了解如何定义验证间隔.

I'm working on application that get the DS from PCF (Pivotal Cloud FoundrY) User provided services. It's working properly but I want to understand how the validation interval is defined.

由于Spring和PCF正在管理我的连接池.我想了解它的工作原理.

As Spring and PCF are managing my connection pool. I'd like to understand how that works.

public DataSource getProfileDS() {    
     PoolConfig poolConfig = new PoolConfig(5, 10, 30000);
     DataSourceConfig dsConfig = new DataSourceConfig(poolConfig, null);
     return connectionFactory().dataSource("profileDS", dsConfig);
}

还有,有什么办法可以像我以前在tomcat下一样自行设置验证间隔吗?

Also, is there any way to set up the validation interval by my own like we are used to do under the tomcat?

推荐答案

春季云如何定义Pivotal Cloud Foundry下的验证间隔?

How spring cloud defines validation interval under the Pivotal Cloud Foundry?

Spring Cloud Config将定义适合您的关系数据库的验证查询.

Spring Cloud Config will define a validation query that is appropriate for your relational database.

示例:

  • 关于验证间隔,它看起来好像没有被配置.相反, Hikari 配置为使用 connectionTestQuery .在从池中获取连接之前进行测试时,不需要设置验证间隔.

    As to the validation interval, it does not look like that's being configured. Instead, the DBCP-like pools use testOnBorrow, and Hikari is configured to use connectionTestQuery. When testing before obtaining a connection from the pool, setting the validation interval is unnecessary.

    还有,有什么办法可以像我以前在tomcat下一样自行设置验证间隔吗?

    Also, is there any way to set up the validation interval by my own like we are used to do under the tomcat?

    如果要使用Spring Cloud Connector,则不需要,但不必使用Spring Cloud Connectors.您还有其他几种方法可以做到这一点.

    Not if you're going to use Spring Cloud Connectors, but you don't have to use Spring Cloud Connectors. There's a couple of other ways you can do this.

    • Spring Boot exposes VCAP_SERVICES as properties like vcap.services.<name>.credentials.username. You could use those to manually define a DataSource. See here.
    • You can use the new java-cfenv library, which is intended to complement Spring Boot better.

    希望有帮助!

    这篇关于Spring Cloud如何定义Pivotal Cloud Foundry下的验证间隔?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆