Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Spring Boot startup failure on couchbase connection error

Using a combination of Spring Boot 1.4.1.Release and Spring Data Couchbase 2.1.3.RELEASE, is there a way to prevent application startup failure if it cannot connect to couchbase?

Current behavior: Application cannot connect to couchbase on startup and exits.

The goal: Application would continue to start even though it cannot connect to Couchbase, use the timeout configurations in CouchbaseEnvironment, and continually try to connect in the background.

In Spring Boot, we can configure Spring JDBC to ignore failure on startup with spring.datasource.continue-on-error=true. Any chance something like that coupled with a retry on failure exists in Spring Data Couchbase?

like image 561
mengchengfeng Avatar asked Nov 09 '16 21:11

mengchengfeng


1 Answers

You can configure CouchbaseEnvironment by overriding getCouchbaseEnvironment using JavaConfig and try increasing the connect timeout. Is there a specific connection failure you are running into?

There isn't continue-on-error property for spring-data-couchbase. This property is available on Spring Boot for relational JDBC and it is useful to ignore initialize failures such as failing to create tables and loading into data sources using scripts.

like image 115
subhashni Avatar answered Sep 30 '22 00:09

subhashni