{"id":428464,"date":"2021-04-18T00:15:13","date_gmt":"2021-04-17T16:15:13","guid":{"rendered":"http:\/\/4563.org\/?p=428464"},"modified":"2021-04-18T00:15:13","modified_gmt":"2021-04-17T16:15:13","slug":"%e6%89%93%e7%ae%97%e7%94%a8-spring-abstractroutingdatasource-%e5%81%9a%e4%b8%80%e4%b8%bb%e5%a4%9a%e4%bb%8e-%e4%bd%86%e6%98%af%e5%92%8c%e4%ba%8b%e5%8a%a1%e6%90%ad%e9%85%8d%e5%ae%9e%e7%8e%b0%e4%b8%8a","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=428464","title":{"rendered":"\u6253\u7b97\u7528 Spring AbstractRoutingDataSource \u505a\u4e00\u4e3b\u591a\u4ece \u4f46\u662f\u548c\u4e8b\u52a1\u642d\u914d\u5b9e\u73b0\u4e0a\u611f\u89c9\u4e0d\u592a\u5bf9\u5934\uff0c\u600e\u4e48\u89e3\u51b3\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6253\u7b97\u7528 Spring AbstractRoutingDataSource \u505a\u4e00\u4e3b\u591a\u4ece \u4f46\u662f\u548c\u4e8b\u52a1\u642d\u914d\u5b9e\u73b0\u4e0a\u611f\u89c9\u4e0d\u592a\u5bf9\u5934\uff0c\u600e\u4e48\u89e3\u51b3\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Aruforce <\/span>  <span><i><\/i> 4<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<h2>\u9700\u6c42<\/h2>\n<pre><code>1. AbstractRoutingDataSource \u60f3\u6839\u636e\u5f53\u524d\u7684\u4e8b\u52a1\u72b6\u6001\u6765 routing  2. \u5728\u4ece\u5e93\u4e0a\u7981\u7528\u66f4\u65b0\u64cd\u4f5c 3. \u6bcf\u4e2a\u8bf7\u6c42 \u6253\u5728\u4e00\u4e2a\u6570\u636e\u6e90\u4e0a <\/code><\/pre>\n<h2>\u95ee\u9898<\/h2>\n<pre><code>1. \u5728\u8fdb\u884c data source routing \u65f6\uff0cTransactionSynchronizationManager.isActualTransactionActive \u603b\u662f\u8fd4\u56de false \uff1b\u6309\u7167\u4ee3\u7801\u7684\u8bed\u4e49\u5b9e\u9645\u4e0a\u662f\u5728\u4e8b\u52a1\u4e4b\u4e2d\u7684\uff1b \u8bf7\u95ee\u6709\u4ec0\u4e48\u5176\u4ed6\u7684 API \u53ef\u4ee5\u4f7f\u7528\u4e48\uff1f 2. \u5728 data source routing \u4e2d\u60f3\u5411 TransactionSynchronizationManager \u6ce8\u518c TransactionSynchronization \u7528\u4e8e\u8d44\u6e90\u6e05\u7406\uff0c\u4f46\u662f\u8fd4\u56de synchronization is not active <\/code><\/pre>\n<h2>stackoverflow \u4f3c\u4e4e\u6709\u4eba\u9047\u5230\u4e86\u76f8\u540c\u7684\u95ee\u9898<\/h2>\n<p>https:\/\/stackoverflow.com\/questions\/9203122\/routing-read-write-transactions-to-primary-and-read-only-transactions-to-replica<\/p>\n<p>Christophe Fondacci \u8fd9\u4e2a\u56de\u7b54\u3002\u3002\u4f3c\u4e4e\u6ca1\u6709\u89e3\u51b3<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>2<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5670633\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : coderwl <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u76f4\u63a5\u7528\u73b0\u6210\u7684\u5427\uff0c\u6211\u53f8\u7528\u7684 sharding-jdbc , \u5199 \/\u8bfb\u64cd\u4f5c\u81ea\u52a8\u8def\u7531\u5230\u4e3b \/\u4ece\u5e93\uff0c\u652f\u6301\u5355\u5e93\u4e8b\u52a1\uff0c\u53ef\u4ee5\u770b\u4e0b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5670634\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Aruforce <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @coderwl \u6211\u4e0d\u662f\u8981\u7528 \u6211\u662f\u8981\u505a\u4e2a\u6539\u9020\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6253\u7b97\u7528 Spring Abstra&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/428464"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=428464"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/428464\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=428464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=428464"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=428464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}