如何解决Spring Data Neo4j:无法在配置的最长时间内从池中获取连接
我正在对使用 spring-boot-starter-data-neo4j 构建的 Neo4j 客户端进行压力测试。
一段时间过去后,应用程序抛出错误无法获取任何请求的连接。
这是我用于 Neo4j 连接的 bean 配置。有人可以检查并告诉可以做什么
id("org.springframework.boot") version "2.4.0"
@Configuration
@EnableTransactionManagement
class Neo4jConfig(
@Value("\${spring.neo4j.uri}")
val neo4jDBUri: String,@Value("\${spring.neo4j.authentication.username}")
val neo4jDbUserName: String,@Value("\${spring.neo4j.authentication.password}")
val neo4jDbUserPassword: String
) : AbstractNeo4jConfig() {
// https://medium.com/neo4j/try-and-then-retry-there-can-be-failure-30bf336383da
@Bean
override fun driver(): Driver {
val config: Config = Config.builder()
.withMaxTransactionRetryTime(60,TimeUnit.SECONDS)
.withLeakedSessionsLogging()
.withRoutingTablePurgeDelay(1,TimeUnit.SECONDS)
.withConnectionAcquisitionTimeout(2 * 60,TimeUnit.SECONDS)
.withConnectionLivenessCheckTimeout(2 * 60,TimeUnit.SECONDS)
.withDriverMetrics()
.withMaxConnectionPoolSize(100)
.build()
return GraphDatabase
.driver(neo4jDBUri,AuthTokens.basic(neo4jDbUserName,neo4jDbUserPassword),config)
}
}
// Refer: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.4.0-M2-Release-Notes#neo4j-1
@Bean(ReactiveNeo4jRepositoryConfigurationExtension.DEFAULT_TRANSACTION_MANAGER_BEAN_NAME)
fun reactiveTransactionManager(
driver: Driver,databaseNameProvider: ReactiveDatabaseSelectionProvider
): ReactiveTransactionManager = ReactiveNeo4jTransactionManager(driver,databaseNameProvider)
// Refer: https://hantsy.medium.com/data-auditing-with-spring-data-neo4j-11d6461146ff
@Configuration(proxyBeanMethods = false)
@EnableReactiveNeo4jAuditing
internal class DataConfig {
@Bean
fun reactiveAuditorAware(): ReactiveAuditorAware<String> = ReactiveAuditorAware { Mono.just("Audit enabled") }
}
错误信息
webFilters.ControllerConfig in Neo4jDriverIO-2-2 - Returning HTTP 400 Bad Requestorg.springframework.dao.InvalidDataAccessResourceUsageException: Unable to acquire connection from the pool within configured maximum time of 120000ms; Error code 'N/A' at org.springframework.data.neo4j.repository.support.Neo4jPersistenceExceptionTranslator.translateImpl(Neo4jPersistenceExceptionTranslator.java:105) Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s): |_ checkpoint ⇢ Handler
controller.UserApiController#createUser(UserReqModel,Continuation) [DispatcherHandler]Stack trace: at org.springframework.data.neo4j.repository.support.Neo4jPersistenceExceptionTranslator.translateImpl(Neo4jPersistenceExceptionTranslator.java:105) at org.springframework.data.neo4j.repository.support.Neo4jPersistenceExceptionTranslator.translateExceptionIfPossible(Neo4jPersistenceExceptionTranslator.java:91) at org.springframework.data.neo4j.core.DefaultReactiveNeo4jClient.potentiallyConvertRuntimeException(DefaultReactiveNeo4jClient.java:271) at org.springframework.data.neo4j.core.DefaultReactiveNeo4jClient.access$200(DefaultReactiveNeo4jClient.java:54) at org.springframework.data.neo4j.core.DefaultReactiveNeo4jClient$DefaultRecordFetchSpec.la
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。