David Roussov
David Roussov

Reputation: 195

Is it possible to read and write to different datasource URLs in Grails 3?

Can a Grails 3 application be configured to perform search queries against a read replica MySQL database, and writes to the original master?

Upvotes: 1

Views: 331

Answers (2)

rafbermudez
rafbermudez

Reputation: 21

You can configure multiple datasources in a Domain class

static mapping = {
    datasources(['datasourceA', 'datasourceB']) 
}

Later, you can use manually 'datasourceA' in reading methods and 'datasourceB' in writting methods.

Link: http://guides.grails.org/grails-multi-datasource/guide/index.html

Upvotes: 1

Denny
Denny

Reputation: 459

Hi My company using grails with aurora mysql - we set 2 data source in grails project when reading or searching we will use reader data source and if we really need to insert or update data , we select by id from writer data source and write/update it back

Upvotes: 0

Related Questions