-
Notifications
You must be signed in to change notification settings - Fork 41.2k
support read only connection datasource #8189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the suggestion. Unfortunately, I don't think we really want to get into the business of auto-configuring multiple data sources. Figuring out the user's intent would start to get very complicated when something like Hibernate is thrown into the mix as well. We have an open issue to provide an example of how to configure multiple data sources. It actually links to a couple of existing examples that may be of interest. Routing read-only requests to a slave is only one example of dynamic routing and there are a huge number of other possibilities. Given this, I don't think it makes sense for Boot to provide one specific custom routing logic implementation. I think that Spring Framework's already got this right. It provides To summarise, the recommendation is:
|
@wilkinsona How would you recommend configuring a single data source as readOnly? I'm autowiring beans via @ConfigurationProperties annotation to instantiate an arbitrary number of DataSourceProperties instances where I occasionally need to mark 1+ of them as readOnly. I'm not using @transactional annotation as I need this across the board for a given data source. Thanks! |
@andyfeller This isn't a great place for questions. We prefer that people use Gitter or Stack Overflow. That said, it depends on your database, doesn't it? I'd probably configure a Datasource with credentials for a user that only has read permissions. |
@wilkinsona Is Gitter a good place ? I am not able to find a way to search in its archives. If it is not possible to use its history then the provided solutions there are not very useful. People will ask the same questions again and again. |
You can search on Gitter. There's a magnifying glass icon on the left-hand side of its UI. |
read only slaves are a fairly common thing. It would be nice if spring boot could support this configuration out of the box for transactions marked as read only with perhaps a secondary "array" of read only datasource configurations (if you have more than one slave).
The text was updated successfully, but these errors were encountered: