{"id":6597,"date":"2025-09-30T11:45:00","date_gmt":"2025-09-30T03:45:00","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=6597"},"modified":"2025-09-29T11:50:32","modified_gmt":"2025-09-29T03:50:32","slug":"%e6%b7%b1%e5%85%a5%e6%8e%a2%e7%b4%a2java%e5%90%8e%e7%ab%af%e5%be%ae%e6%9c%8d%e5%8a%a1%e6%9e%b6%e6%9e%84%e4%b8%ad%e7%9a%84%e5%88%86%e5%b8%83%e5%bc%8f%e4%ba%8b%e5%8a%a1%e7%ae%a1%e7%90%86","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/java\/%e6%b7%b1%e5%85%a5%e6%8e%a2%e7%b4%a2java%e5%90%8e%e7%ab%af%e5%be%ae%e6%9c%8d%e5%8a%a1%e6%9e%b6%e6%9e%84%e4%b8%ad%e7%9a%84%e5%88%86%e5%b8%83%e5%bc%8f%e4%ba%8b%e5%8a%a1%e7%ae%a1%e7%90%86\/","title":{"rendered":"\u6df1\u5165\u63a2\u7d22Java\u540e\u7aef\u5fae\u670d\u52a1\u67b6\u6784\u4e2d\u7684\u5206\u5e03\u5f0f\u4e8b\u52a1\u7ba1\u7406"},"content":{"rendered":"\n<p>\u5728\u5fae\u670d\u52a1\u67b6\u6784\u4e2d\uff0c\u7cfb\u7edf\u88ab\u62c6\u5206\u4e3a\u591a\u4e2a\u72ec\u7acb\u7684\u670d\u52a1\uff0c\u6bcf\u4e2a\u670d\u52a1\u53ef\u80fd\u62e5\u6709\u81ea\u5df1\u7684\u6570\u636e\u5e93\uff08\u5982MySQL\u3001PostgreSQL\u6216MongoDB\uff09\u3002\u8fd9\u79cd\u67b6\u6784\u63d0\u9ad8\u4e86\u7cfb\u7edf\u7684\u53ef\u6269\u5c55\u6027\u548c\u7075\u6d3b\u6027\uff0c\u4f46\u4e5f\u5e26\u6765\u4e86\u6570\u636e\u4e00\u81f4\u6027\u7684\u6311\u6218\u3002\u4f20\u7edf\u7684\u672c\u5730\u4e8b\u52a1\uff08Local Transaction\uff09\u65e0\u6cd5\u6ee1\u8db3\u8de8\u670d\u52a1\u3001\u8de8\u6570\u636e\u5e93\u7684\u573a\u666f\uff0c\u5206\u5e03\u5f0f\u4e8b\u52a1\u5e94\u8fd0\u800c\u751f\u3002<\/p>\n\n\n\n<p>\u5206\u5e03\u5f0f\u4e8b\u52a1\u7684\u76ee\u6807\u662f\u786e\u4fdd\u5728\u591a\u4e2a\u670d\u52a1\u6216\u6570\u636e\u5e93\u4e4b\u95f4\u64cd\u4f5c\u65f6\uff0c\u6570\u636e\u4fdd\u6301\u4e00\u81f4\u6027\uff0c\u5373\u6ee1\u8db3ACID\uff08\u539f\u5b50\u6027\u3001\u4e00\u81f4\u6027\u3001\u9694\u79bb\u6027\u3001\u6301\u4e45\u6027\uff09\u7279\u6027\u3002Java\u751f\u6001\u63d0\u4f9b\u4e86\u591a\u79cd\u5206\u5e03\u5f0f\u4e8b\u52a1\u89e3\u51b3\u65b9\u6848\uff0c\u5982Seata\u3001Spring Cloud Alibaba\u7684\u4e8b\u52a1\u652f\u6301\uff0c\u4ee5\u53caRocketMQ\u7684\u4e8b\u52a1\u6d88\u606f\u673a\u5236\u3002\u672c\u6587\u5c06\u4ee5Seata\u4e3a\u6838\u5fc3\uff0c\u7ed3\u5408Spring Cloud Alibaba\u3001RocketMQ\u548cDocker\uff0c\u6df1\u5165\u8bb2\u89e3\u5206\u5e03\u5f0f\u4e8b\u52a1\u7684\u5b9e\u73b0\u3001\u4f18\u5316\u53ca\u5b9e\u9645\u5e94\u7528\u573a\u666f\uff0c\u540c\u65f6\u878d\u5165AI\u6280\u672f\u5728\u4e8b\u52a1\u76d1\u63a7\u548c\u4f18\u5316\u4e2d\u7684\u5e94\u7528\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e00\u3001\u5206\u5e03\u5f0f\u4e8b\u52a1\u7684\u6838\u5fc3\u6982\u5ff5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1.1 \u5206\u5e03\u5f0f\u4e8b\u52a1\u7684\u5b9a\u4e49\u4e0e\u6311\u6218<\/h3>\n\n\n\n<p>\u5206\u5e03\u5f0f\u4e8b\u52a1\u662f\u6307\u6d89\u53ca\u591a\u4e2a\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u6570\u636e\u5e93\u64cd\u4f5c\uff0c\u9700\u8981\u4fdd\u8bc1\u8fd9\u4e9b\u64cd\u4f5c\u8981\u4e48\u5168\u90e8\u6210\u529f\uff0c\u8981\u4e48\u5168\u90e8\u5931\u8d25\u3002\u5728\u5fae\u670d\u52a1\u67b6\u6784\u4e2d\uff0c\u5206\u5e03\u5f0f\u4e8b\u52a1\u9762\u4e34\u4ee5\u4e0b\u6311\u6218\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7f51\u7edc\u5ef6\u8fdf\u4e0e\u6545\u969c<\/strong>\uff1a\u670d\u52a1\u95f4\u901a\u8fc7\u7f51\u7edc\u901a\u4fe1\uff0c\u5ef6\u8fdf\u3001\u8d85\u65f6\u6216\u8282\u70b9\u6545\u969c\u53ef\u80fd\u5bfc\u81f4\u4e8b\u52a1\u5931\u8d25\u3002<\/li>\n\n\n\n<li><strong>\u6570\u636e\u9694\u79bb\u6027<\/strong>\uff1a\u591a\u4e2a\u670d\u52a1\u5e76\u53d1\u8bbf\u95ee\u4e0d\u540c\u6570\u636e\u5e93\uff0c\u53ef\u80fd\u5f15\u53d1\u6570\u636e\u4e0d\u4e00\u81f4\u3002<\/li>\n\n\n\n<li><strong>\u6027\u80fd\u74f6\u9888<\/strong>\uff1a\u5206\u5e03\u5f0f\u4e8b\u52a1\u901a\u5e38\u6d89\u53ca\u591a\u65b9\u534f\u8c03\uff0c\u6027\u80fd\u5f00\u9500\u8f83\u5927\u3002<\/li>\n\n\n\n<li><strong>\u590d\u6742\u6027<\/strong>\uff1a\u4e8b\u52a1\u7684\u56de\u6eda\u3001\u8865\u507f\u673a\u5236\u5b9e\u73b0\u590d\u6742\uff0c\u9700\u8003\u8651\u5404\u79cd\u5f02\u5e38\u573a\u666f\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">1.2 \u5206\u5e03\u5f0f\u4e8b\u52a1\u7684\u5e38\u89c1\u6a21\u578b<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u4e24\u9636\u6bb5\u63d0\u4ea4\uff082PC\uff09<\/strong>\uff1a\u901a\u8fc7\u534f\u8c03\u8005\uff08Coordinator\uff09\u5206\u9636\u6bb5\u63d0\u4ea4\u4e8b\u52a1\uff0c\u5206\u4e3a\u51c6\u5907\u9636\u6bb5\uff08Prepare\uff09\u548c\u63d0\u4ea4\u9636\u6bb5\uff08Commit\uff09\u3002Seata\u7684AT\u6a21\u5f0f\u57fa\u4e8e\u6b64\u3002<\/li>\n\n\n\n<li><strong>\u8865\u507f\u4e8b\u52a1\uff08TCC\uff09<\/strong>\uff1a\u901a\u8fc7Try-Confirm-Cancel\u4e09\u9636\u6bb5\u64cd\u4f5c\uff0c\u624b\u52a8\u5b9e\u73b0\u4e8b\u52a1\u7684\u8865\u507f\u903b\u8f91\u3002<\/li>\n\n\n\n<li><strong>Saga\u6a21\u5f0f<\/strong>\uff1a\u5c06\u4e8b\u52a1\u62c6\u5206\u4e3a\u4e00\u7cfb\u5217\u672c\u5730\u4e8b\u52a1\uff0c\u901a\u8fc7\u4e8b\u4ef6\u9a71\u52a8\u6216\u7f16\u6392\u5b9e\u73b0\u6700\u7ec8\u4e00\u81f4\u6027\u3002<\/li>\n\n\n\n<li><strong>\u4e8b\u52a1\u6d88\u606f<\/strong>\uff1a\u5229\u7528\u6d88\u606f\u961f\u5217\uff08\u5982RocketMQ\uff09\u7684\u4e8b\u52a1\u6d88\u606f\u529f\u80fd\uff0c\u786e\u4fdd\u6d88\u606f\u53d1\u9001\u4e0e\u6570\u636e\u5e93\u64cd\u4f5c\u4e00\u81f4\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u672c\u6587\u5c06\u91cd\u70b9\u8bb2\u89e3Seata\u7684AT\u6a21\u5f0f\uff08\u81ea\u52a8\u4e8b\u52a1\uff09\u548cRocketMQ\u7684\u4e8b\u52a1\u6d88\u606f\u673a\u5236\uff0c\u7ed3\u5408Spring Cloud Alibaba\u5b9e\u73b0\u5fae\u670d\u52a1\u573a\u666f\u4e0b\u7684\u5206\u5e03\u5f0f\u4e8b\u52a1\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001Seata\uff1a\u5206\u5e03\u5f0f\u4e8b\u52a1\u7684\u5229\u5668<\/h2>\n\n\n\n<p>Seata\uff08Simple Extensible Autonomous Transaction Architecture\uff09\u662f\u963f\u91cc\u5df4\u5df4\u5f00\u6e90\u7684\u5206\u5e03\u5f0f\u4e8b\u52a1\u6846\u67b6\uff0c\u652f\u6301AT\u3001TCC\u3001Saga\u548cXA\u7b49\u591a\u79cd\u6a21\u5f0f\u3002\u672c\u6587\u91cd\u70b9\u63a2\u8ba8AT\u6a21\u5f0f\uff0c\u56e0\u5176\u5bf9\u5f00\u53d1\u8005\u7684\u4fb5\u5165\u6027\u4f4e\uff0c\u9002\u5408\u5feb\u901f\u96c6\u6210\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2.1 Seata\u7684AT\u6a21\u5f0f\u5de5\u4f5c\u539f\u7406<\/h3>\n\n\n\n<p>AT\uff08Automatic Transaction\uff09\u6a21\u5f0f\u57fa\u4e8e\u4e24\u9636\u6bb5\u63d0\u4ea4\uff0c\u901a\u8fc7\u4ee3\u7406\u6570\u636e\u6e90\u81ea\u52a8\u7ba1\u7406\u4e8b\u52a1\u7684\u63d0\u4ea4\u4e0e\u56de\u6eda\u3002\u5176\u6838\u5fc3\u7ec4\u4ef6\u5305\u62ec\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>TC\uff08Transaction Coordinator\uff09<\/strong>\uff1a\u4e8b\u52a1\u534f\u8c03\u8005\uff0c\u8d1f\u8d23\u5168\u5c40\u4e8b\u52a1\u7684\u534f\u8c03\u3002<\/li>\n\n\n\n<li><strong>TM\uff08Transaction Manager\uff09<\/strong>\uff1a\u4e8b\u52a1\u7ba1\u7406\u5668\uff0c\u5b9a\u4e49\u5168\u5c40\u4e8b\u52a1\u7684\u8303\u56f4\uff0c\u53d1\u8d77\u63d0\u4ea4\u6216\u56de\u6eda\u3002<\/li>\n\n\n\n<li><strong>RM\uff08Resource Manager\uff09<\/strong>\uff1a\u8d44\u6e90\u7ba1\u7406\u5668\uff0c\u7ba1\u7406\u5206\u652f\u4e8b\u52a1\uff0c\u8d1f\u8d23\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u5de5\u4f5c\u6d41\u7a0b<\/strong>\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u7b2c\u4e00\u9636\u6bb5\uff08Prepare\uff09<\/strong>\uff1a\u6bcf\u4e2a\u5206\u652f\u4e8b\u52a1\u6267\u884c\u672c\u5730SQL\uff0c\u8bb0\u5f55\u524d\u955c\u50cf\uff08Before Image\uff09\u548c\u540e\u955c\u50cf\uff08After Image\uff09\uff0c\u5e76\u751f\u6210undo_log\u65e5\u5fd7\u3002<\/li>\n\n\n\n<li><strong>\u7b2c\u4e8c\u9636\u6bb5\uff08Commit\/Rollback\uff09<\/strong>\uff1aTC\u6839\u636eTM\u7684\u6307\u4ee4\uff0c\u901a\u77e5\u5404RM\u63d0\u4ea4\u6216\u56de\u6eda\u4e8b\u52a1\u3002\u56de\u6eda\u65f6\u6839\u636eundo_log\u6062\u590d\u6570\u636e\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">2.2 Seata\u4e0eSpring Cloud Alibaba\u96c6\u6210<\/h3>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u57fa\u4e8eSpring Boot\u3001Spring Cloud Alibaba\u548cSeata\u7684\u5206\u5e03\u5f0f\u4e8b\u52a1\u5b9e\u73b0\u793a\u4f8b\uff0c\u6a21\u62df\u8ba2\u5355\u670d\u52a1\u548c\u5e93\u5b58\u670d\u52a1\u7684\u4e8b\u52a1\u534f\u8c03\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u73af\u5883\u51c6\u5907<\/h4>\n\n\n\n<p>\u786e\u4fdd\u4ee5\u4e0b\u4f9d\u8d56\u5df2\u914d\u7f6e\uff08\u57fa\u4e8eMaven\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;dependencies&gt;<\/code><code>&nbsp; &nbsp;&nbsp;&lt;dependency&gt;<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;<\/code><code>&nbsp; &nbsp;&nbsp;&lt;\/dependency&gt;<\/code><code>&nbsp; &nbsp;&nbsp;&lt;dependency&gt;<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;groupId&gt;com.alibaba.cloud&lt;\/groupId&gt;<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;artifactId&gt;spring-cloud-starter-alibaba-seata&lt;\/artifactId&gt;<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;version&gt;2021.0.1.0&lt;\/version&gt;<\/code><code>&nbsp; &nbsp;&nbsp;&lt;\/dependency&gt;<\/code><code>&nbsp; &nbsp;&nbsp;&lt;dependency&gt;<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;groupId&gt;mysql&lt;\/groupId&gt;<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;artifactId&gt;mysql-connector-java&lt;\/artifactId&gt;<\/code><code>&nbsp; &nbsp;&nbsp;&lt;\/dependency&gt;<\/code><code>&lt;\/dependencies&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u914d\u7f6eSeata<\/h4>\n\n\n\n<p>\u5728<code>application.yml<\/code>\u4e2d\u914d\u7f6eSeata\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>spring:<\/code><code>&nbsp; cloud:<\/code><code>&nbsp; &nbsp; alibaba:<\/code><code>&nbsp; &nbsp; &nbsp; seata:<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; tx-service-group: my_tx_group<\/code><code>seata:<\/code><code>&nbsp; enabled:&nbsp;true<\/code><code>&nbsp; application-id:&nbsp;order-service<\/code><code>&nbsp; tx-service-group: my_tx_group<\/code><code>&nbsp; service:<\/code><code>&nbsp; &nbsp; vgroup-mapping:<\/code><code>&nbsp; &nbsp; &nbsp; my_tx_group:&nbsp;default<\/code><code>&nbsp; &nbsp; grouplist:<\/code><code>&nbsp; &nbsp; &nbsp;&nbsp;default:&nbsp;127.0.0.1:8091<\/code><code>&nbsp; registry:<\/code><code>&nbsp; &nbsp; type: nacos<\/code><code>&nbsp; &nbsp; nacos:<\/code><code>&nbsp; &nbsp; &nbsp; server-addr: localhost:8848<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u4ee3\u7801\u793a\u4f8b\uff1a\u8ba2\u5355\u670d\u52a1\u4e0e\u5e93\u5b58\u670d\u52a1<\/h4>\n\n\n\n<p><strong>\u8ba2\u5355\u670d\u52a1\uff08OrderService\uff09<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>@Service<\/code><code>public&nbsp;class&nbsp;OrderService&nbsp;{<\/code><code>&nbsp; &nbsp;&nbsp;@Autowired<\/code><code>&nbsp; &nbsp;&nbsp;private&nbsp;OrderMapper&nbsp;orderMapper;<\/code><code>&nbsp; &nbsp;&nbsp;@Autowired<\/code><code>&nbsp; &nbsp;&nbsp;private&nbsp;InventoryService&nbsp;inventoryService;&nbsp;\/\/ Feign\u5ba2\u6237\u7aef\u8c03\u7528\u5e93\u5b58\u670d\u52a1<\/code><code>&nbsp; &nbsp;&nbsp;@GlobalTransactional(name =&nbsp;\"create-order\", rollbackFor =&nbsp;Exception.class)<\/code><code>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;createOrder(Order order) {<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ 1. \u521b\u5efa\u8ba2\u5355<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; orderMapper.insert(order);<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ 2. \u8c03\u7528\u5e93\u5b58\u670d\u52a1\u6263\u51cf\u5e93\u5b58<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; inventoryService.deductInventory(order.getProductId(), order.getQuantity());<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ \u6a21\u62df\u5f02\u5e38<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(order.getQuantity() &lt;&nbsp;0) {<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;throw&nbsp;new&nbsp;RuntimeException(\"Invalid quantity\");<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; }<\/code><code>&nbsp; &nbsp; }<\/code><code>}<\/code><\/pre>\n\n\n\n<p><strong>\u5e93\u5b58\u670d\u52a1\uff08InventoryService\uff09<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>@Service<\/code><code>public&nbsp;class&nbsp;InventoryService&nbsp;{<\/code><code>&nbsp; &nbsp;&nbsp;@Autowired<\/code><code>&nbsp; &nbsp;&nbsp;private&nbsp;InventoryMapper&nbsp;inventoryMapper;<\/code><code>&nbsp; &nbsp;&nbsp;@Transactional<\/code><code>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;deductInventory(Long productId, Integer quantity) {<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;Inventory&nbsp;inventory = inventoryMapper.selectByProductId(productId);<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(inventory.getStock() &lt; quantity) {<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;throw&nbsp;new&nbsp;RuntimeException(\"Insufficient stock\");<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; }<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; inventory.setStock(inventory.getStock() - quantity);<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; inventoryMapper.update(inventory);<\/code><code>&nbsp; &nbsp; }<\/code><code>}<\/code><\/pre>\n\n\n\n<p><strong>\u8bf4\u660e<\/strong>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>@GlobalTransactional<\/code>\u6ce8\u89e3\u6807\u8bb0\u5168\u5c40\u4e8b\u52a1\uff0cSeata\u4f1a\u81ea\u52a8\u534f\u8c03\u8ba2\u5355\u670d\u52a1\u548c\u5e93\u5b58\u670d\u52a1\u7684\u4e8b\u52a1\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u5e93\u5b58\u4e0d\u8db3\u6216\u8ba2\u5355\u6570\u91cf\u65e0\u6548\uff0cSeata\u4f1a\u89e6\u53d1\u56de\u6eda\uff0c\u786e\u4fdd\u6570\u636e\u4e00\u81f4\u6027\u3002<\/li>\n\n\n\n<li>Seata\u7684AT\u6a21\u5f0f\u901a\u8fc7\u4ee3\u7406\u6570\u636e\u6e90\u81ea\u52a8\u8bb0\u5f55undo_log\uff0c\u5f00\u53d1\u8005\u65e0\u9700\u624b\u52a8\u5b9e\u73b0\u8865\u507f\u903b\u8f91\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001RocketMQ\u4e8b\u52a1\u6d88\u606f\uff1a\u4e8b\u4ef6\u9a71\u52a8\u7684\u5206\u5e03\u5f0f\u4e8b\u52a1<\/h2>\n\n\n\n<p>RocketMQ\u63d0\u4f9b\u7684\u4e8b\u52a1\u6d88\u606f\u673a\u5236\u9002\u7528\u4e8e\u4e8b\u4ef6\u9a71\u52a8\u7684\u5206\u5e03\u5f0f\u4e8b\u52a1\u573a\u666f\uff0c\u901a\u8fc7\u534a\u6d88\u606f\uff08Half Message\uff09\u548c\u4e8b\u52a1\u72b6\u6001\u56de\u67e5\u5b9e\u73b0\u6700\u7ec8\u4e00\u81f4\u6027\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3.1 RocketMQ\u4e8b\u52a1\u6d88\u606f\u539f\u7406<\/h3>\n\n\n\n<p>RocketMQ\u4e8b\u52a1\u6d88\u606f\u5206\u4e3a\u4e24\u9636\u6bb5\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u53d1\u9001\u534a\u6d88\u606f<\/strong>\uff1a\u751f\u4ea7\u8005\u53d1\u9001\u4e00\u6761\u201c\u534a\u6d88\u606f\u201d\u5230Broker\uff0c\u6d88\u8d39\u8005\u6682\u65f6\u4e0d\u53ef\u89c1\u3002<\/li>\n\n\n\n<li><strong>\u6267\u884c\u672c\u5730\u4e8b\u52a1<\/strong>\uff1a\u751f\u4ea7\u8005\u6267\u884c\u672c\u5730\u6570\u636e\u5e93\u64cd\u4f5c\uff0c\u5e76\u6839\u636e\u7ed3\u679c\u63d0\u4ea4\uff08Commit\uff09\u6216\u56de\u6eda\uff08Rollback\uff09\u534a\u6d88\u606f\u3002<\/li>\n\n\n\n<li><strong>\u4e8b\u52a1\u56de\u67e5<\/strong>\uff1a\u82e5Broker\u672a\u6536\u5230\u786e\u8ba4\uff0c\u5b9a\u65f6\u56de\u67e5\u751f\u4ea7\u8005\u4e8b\u52a1\u72b6\u6001\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">3.2 \u4ee3\u7801\u793a\u4f8b\uff1aRocketMQ\u4e8b\u52a1\u6d88\u606f<\/h3>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u8ba2\u5355\u670d\u52a1\u901a\u8fc7RocketMQ\u4e8b\u52a1\u6d88\u606f\u901a\u77e5\u5e93\u5b58\u670d\u52a1\u7684\u793a\u4f8b\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u914d\u7f6eRocketMQ<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;dependency&gt;<\/code><code>&nbsp; &nbsp;&nbsp;&lt;groupId&gt;org.apache.rocketmq&lt;\/groupId&gt;<\/code><code>&nbsp; &nbsp;&nbsp;&lt;artifactId&gt;rocketmq-spring-boot-starter&lt;\/artifactId&gt;<\/code><code>&nbsp; &nbsp;&nbsp;&lt;version&gt;2.2.0&lt;\/version&gt;<\/code><code>&lt;\/dependency&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u751f\u4ea7\u8005\u4ee3\u7801<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>@Service<\/code><code>public&nbsp;class&nbsp;OrderService&nbsp;{<\/code><code>&nbsp; &nbsp;&nbsp;@Autowired<\/code><code>&nbsp; &nbsp;&nbsp;private&nbsp;RocketMQTemplate&nbsp;rocketMQTemplate;<\/code><code>&nbsp; &nbsp;&nbsp;@Autowired<\/code><code>&nbsp; &nbsp;&nbsp;private&nbsp;OrderMapper&nbsp;orderMapper;<\/code><code>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;createOrderWithMQ(Order order) {<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; rocketMQTemplate.sendMessageInTransaction(<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"order-topic:tag\",<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;MessageBuilder.withPayload(order).build(),<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; order<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; );<\/code><code>&nbsp; &nbsp; }<\/code><code>&nbsp; &nbsp;&nbsp;@RocketMQTransactionListener(txProducerGroup =&nbsp;\"order-tx-group\")<\/code><code>&nbsp; &nbsp;&nbsp;public&nbsp;class&nbsp;OrderTransactionListener&nbsp;implements&nbsp;RocketMQLocalTransactionListener&nbsp;{<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;@Override<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;public&nbsp;RocketMQLocalTransactionState&nbsp;executeLocalTransaction(Message msg,&nbsp;Object&nbsp;arg) {<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;Order&nbsp;order = (Order) arg;<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;try&nbsp;{<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ \u6267\u884c\u672c\u5730\u4e8b\u52a1<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; orderMapper.insert(order);<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;RocketMQLocalTransactionState.COMMIT;<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;catch&nbsp;(Exception&nbsp;e) {<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;RocketMQLocalTransactionState.ROLLBACK;<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; }<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;@Override<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;public&nbsp;RocketMQLocalTransactionState&nbsp;checkLocalTransaction(Message msg) {<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ \u56de\u67e5\u903b\u8f91<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;Order&nbsp;order = orderMapper.selectById(msg.getHeaders().get(\"orderId\"));<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;order !=&nbsp;null&nbsp;?&nbsp;RocketMQLocalTransactionState.COMMIT&nbsp;:&nbsp;RocketMQLocalTransactionState.ROLLBACK;<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; }<\/code><code>&nbsp; &nbsp; }<\/code><code>}<\/code><\/pre>\n\n\n\n<p><strong>\u6d88\u8d39\u8005\u4ee3\u7801<\/strong>\uff1a<\/p>\n\n\n\n<p><code>@RocketMQMessageListener(\u00a0 \u00a0 topic =\u00a0\"order-topic\",\u00a0 \u00a0 consumerGroup =\u00a0\"inventory-consumer-group\",\u00a0 \u00a0 selectorExpression =\u00a0\"tag\")@Servicepublic\u00a0class\u00a0InventoryConsumer\u00a0{\u00a0 \u00a0\u00a0@Autowired\u00a0 \u00a0\u00a0private\u00a0InventoryService\u00a0inventoryService;\u00a0 \u00a0\u00a0@Override\u00a0 \u00a0\u00a0public\u00a0void\u00a0onMessage(Order order) {\u00a0 \u00a0 \u00a0 \u00a0 inventoryService.deductInventory(order.getProductId(), order.getQuantity());\u00a0 \u00a0 }}<\/code><\/p>\n\n\n\n<p><strong>\u8bf4\u660e<\/strong>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u751f\u4ea7\u8005\u5728\u53d1\u9001\u534a\u6d88\u606f\u540e\u6267\u884c\u672c\u5730\u4e8b\u52a1\uff0c\u6210\u529f\u5219\u63d0\u4ea4\u6d88\u606f\uff0c\u5931\u8d25\u5219\u56de\u6eda\u3002<\/li>\n\n\n\n<li>\u6d88\u8d39\u8005\u5728\u6536\u5230\u6d88\u606f\u540e\u6267\u884c\u5e93\u5b58\u6263\u51cf\uff0c\u786e\u4fdd\u6700\u7ec8\u4e00\u81f4\u6027\u3002<\/li>\n\n\n\n<li>\u4e8b\u52a1\u56de\u67e5\u673a\u5236\u9632\u6b62\u6d88\u606f\u4e22\u5931\u6216\u91cd\u590d\u6d88\u8d39\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u56db\u3001\u6027\u80fd\u4f18\u5316\u4e0e\u76d1\u63a7<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">4.1 \u6027\u80fd\u4f18\u5316\u7b56\u7565<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Seata\u4f18\u5316<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><strong>\u51cf\u5c11\u9501\u51b2\u7a81<\/strong>\uff1a\u4f18\u5316SQL\u8bed\u53e5\uff0c\u51cf\u5c11\u884c\u9501\u8303\u56f4\u3002<\/li>\n\n\n\n<li><strong>\u5f02\u6b65\u5316<\/strong>\uff1a\u5c06\u975e\u5173\u952e\u64cd\u4f5c\uff08\u5982\u65e5\u5fd7\u8bb0\u5f55\uff09\u5f02\u6b65\u5904\u7406\uff0c\u964d\u4f4e\u4e8b\u52a1\u65f6\u957f\u3002<\/li>\n\n\n\n<li><strong>\u5206\u5e03\u5f0f\u9501<\/strong>\uff1a\u7ed3\u5408Redis\uff08\u5982Redisson\uff09\u5b9e\u73b0\u5206\u5e03\u5f0f\u9501\uff0c\u907f\u514d\u5e76\u53d1\u51b2\u7a81\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>RocketMQ\u4f18\u5316<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><strong>\u6279\u91cf\u6d88\u606f<\/strong>\uff1a\u6279\u91cf\u53d1\u9001\u6d88\u606f\uff0c\u51cf\u5c11\u7f51\u7edc\u5f00\u9500\u3002<\/li>\n\n\n\n<li><strong>\u6d88\u8d39\u8005\u5e76\u53d1<\/strong>\uff1a\u8c03\u6574\u6d88\u8d39\u8005\u7ebf\u7a0b\u6c60\u5927\u5c0f\uff0c\u63d0\u5347\u6d88\u606f\u5904\u7406\u6548\u7387\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u6570\u636e\u5e93\u4f18\u5316<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528MySQL\u7d22\u5f15\u4f18\u5316\u67e5\u8be2\u6027\u80fd\u3002<\/li>\n\n\n\n<li>\u7ed3\u5408Redis\u7f13\u5b58\u70ed\u70b9\u6570\u636e\uff0c\u51cf\u5c11\u6570\u636e\u5e93\u538b\u529b\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">4.2 \u76d1\u63a7\u4e0e\u65e5\u5fd7<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Prometheus\u4e0eGrafana<\/strong>\uff1a\u76d1\u63a7Seata\u4e8b\u52a1\u6210\u529f\u7387\u3001RocketMQ\u6d88\u606f\u5ef6\u8fdf\u7b49\u6307\u6807\u3002<\/li>\n\n\n\n<li><strong>ELK<\/strong>\uff1a\u6536\u96c6\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u65e5\u5fd7\uff0c\u5206\u6790\u4e8b\u52a1\u5931\u8d25\u539f\u56e0\u3002<\/li>\n\n\n\n<li><strong>Zipkin<\/strong>\uff1a\u8ffd\u8e2a\u4e8b\u52a1\u8c03\u7528\u94fe\uff0c\u5b9a\u4f4d\u6027\u80fd\u74f6\u9888\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">\u914d\u7f6ePrometheus\u76d1\u63a7Seata<\/h4>\n\n\n\n<p>\u5728<code>application.yml<\/code>\u4e2d\u542f\u7528Actuator\u7aef\u70b9\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"849\" height=\"201\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\" class=\"wp-image-6601 lazyload\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708.png 849w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708-300x71.png 300w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708-768x182.png 768w\" sizes=\"auto, (max-width: 849px) 100vw, 849px\" \/><noscript><img loading=\"lazy\" decoding=\"async\" width=\"849\" height=\"201\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708.png\" alt=\"\" class=\"wp-image-6601\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708.png 849w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708-300x71.png 300w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708-768x182.png 768w\" sizes=\"auto, (max-width: 849px) 100vw, 849px\" \/><\/noscript><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\"><\/pre>\n\n\n\n<p>Prometheus\u914d\u7f6e\u6587\u4ef6\uff08<code>prometheus.yml<\/code>\uff09\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"846\" height=\"201\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034820687.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\" class=\"wp-image-6600 lazyload\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034820687.png 846w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034820687-300x71.png 300w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034820687-768x182.png 768w\" sizes=\"auto, (max-width: 846px) 100vw, 846px\" \/><noscript><img loading=\"lazy\" decoding=\"async\" width=\"846\" height=\"201\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034820687.png\" alt=\"\" class=\"wp-image-6600\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034820687.png 846w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034820687-300x71.png 300w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034820687-768x182.png 768w\" sizes=\"auto, (max-width: 846px) 100vw, 846px\" \/><\/noscript><\/figure>\n\n\n\n<p>Grafana\u4e2d\u914d\u7f6e\u4eea\u8868\u76d8\uff0c\u5c55\u793a\u4e8b\u52a1\u6210\u529f\u7387\u3001\u54cd\u5e94\u65f6\u95f4\u7b49\u6307\u6807\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e94\u3001AI\u6280\u672f\u5728\u5206\u5e03\u5f0f\u4e8b\u52a1\u4e2d\u7684\u5e94\u7528<\/h2>\n\n\n\n<p>AI\u6280\u672f\u53ef\u663e\u8457\u63d0\u5347\u5206\u5e03\u5f0f\u4e8b\u52a1\u7684\u6548\u7387\u4e0e\u53ef\u9760\u6027\uff0c\u4ee5\u4e0b\u662f\u51e0\u79cd\u5178\u578b\u5e94\u7528\u573a\u666f\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u4e8b\u52a1\u5f02\u5e38\u9884\u6d4b<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528\u673a\u5668\u5b66\u4e60\u6a21\u578b\uff08\u5982XGBoost\uff09\u5206\u6790\u5386\u53f2\u4e8b\u52a1\u65e5\u5fd7\uff0c\u9884\u6d4b\u53ef\u80fd\u5bfc\u81f4\u5931\u8d25\u7684\u573a\u666f\u3002<\/li>\n\n\n\n<li>\u5de5\u5177\u63a8\u8350\uff1a<strong>TensorFlow<\/strong>\uff08https:\/\/www.tensorflow.org\uff09\u6216**PyTorch**\uff08https:\/\/pytorch.org\uff09\uff0c\u53ef\u96c6\u6210\u5230Java\u9879\u76ee\u4e2d\u901a\u8fc7REST\u00a0API\u8c03\u7528\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u81ea\u52a8\u4f18\u5316\u4e8b\u52a1\u7b56\u7565<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>AI\u7b97\u6cd5\u53ef\u52a8\u6001\u8c03\u6574\u4e8b\u52a1\u91cd\u8bd5\u7b56\u7565\u6216\u8def\u7531\u9009\u62e9\uff0c\u4f18\u5316\u6027\u80fd\u3002<\/li>\n\n\n\n<li>\u5de5\u5177\u63a8\u8350\uff1a<strong>Apache Airflow<\/strong>\uff08https:\/\/airflow.apache.org\uff09\u7528\u4e8e\u5de5\u4f5c\u6d41\u8c03\u5ea6\uff0c\u7ed3\u5408AI\u6a21\u578b\u4f18\u5316\u4e8b\u52a1\u6d41\u7a0b\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u667a\u80fd\u76d1\u63a7<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u7ed3\u5408ELK\u548cAI\u5206\u6790\u65e5\u5fd7\uff0c\u81ea\u52a8\u8bc6\u522b\u5f02\u5e38\u6a21\u5f0f\u5e76\u62a5\u8b66\u3002<\/li>\n\n\n\n<li>\u5de5\u5177\u63a8\u8350\uff1a<strong>Kibana<\/strong>\uff08https:\/\/www.elastic.co\/kibana\uff09\u4e0e\u673a\u5668\u5b66\u4e60\u63d2\u4ef6\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u793a\u4f8b\uff1aAI\u9a71\u52a8\u7684\u4e8b\u52a1\u91cd\u8bd5<\/h4>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"849\" height=\"597\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034814153.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\" class=\"wp-image-6599 lazyload\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034814153.png 849w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034814153-300x211.png 300w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034814153-768x540.png 768w\" sizes=\"auto, (max-width: 849px) 100vw, 849px\" \/><noscript><img loading=\"lazy\" decoding=\"async\" width=\"849\" height=\"597\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034814153.png\" alt=\"\" class=\"wp-image-6599\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034814153.png 849w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034814153-300x211.png 300w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034814153-768x540.png 768w\" sizes=\"auto, (max-width: 849px) 100vw, 849px\" \/><\/noscript><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\"><\/pre>\n\n\n\n<p><strong>\u8bf4\u660e<\/strong>\uff1aAI\u6a21\u578b\u6839\u636e\u4e8b\u52a1\u590d\u6742\u5ea6\u9884\u6d4b\u6700\u4f73\u91cd\u8bd5\u6b21\u6570\uff0c\u51cf\u5c11\u76f2\u76ee\u91cd\u8bd5\u7684\u8d44\u6e90\u6d6a\u8d39\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u516d\u3001Docker\u90e8\u7f72\u5b9e\u8df5<\/h2>\n\n\n\n<p>\u4f7f\u7528Docker\u90e8\u7f72Seata\u3001RocketMQ\u548cSpring Boot\u5e94\u7528\uff0c\u786e\u4fdd\u73af\u5883\u4e00\u81f4\u6027\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6.1 Docker Compose\u914d\u7f6e<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"849\" height=\"915\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034813766.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\" class=\"wp-image-6598 lazyload\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034813766.png 849w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034813766-278x300.png 278w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034813766-768x828.png 768w\" sizes=\"auto, (max-width: 849px) 100vw, 849px\" \/><noscript><img loading=\"lazy\" decoding=\"async\" width=\"849\" height=\"915\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034813766.png\" alt=\"\" class=\"wp-image-6598\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034813766.png 849w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034813766-278x300.png 278w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034813766-768x828.png 768w\" sizes=\"auto, (max-width: 849px) 100vw, 849px\" \/><\/noscript><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code><br><br><\/code><\/pre>\n\n\n\n<p><strong>\u8bf4\u660e<\/strong>\uff1aDocker Compose\u4e00\u952e\u542f\u52a8Seata\u670d\u52a1\u5668\u3001RocketMQ\u548c\u8ba2\u5355\u670d\u52a1\uff0c\u7b80\u5316\u90e8\u7f72\u6d41\u7a0b\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e03\u3001\u6027\u80fd\u5bf9\u6bd4\u4e0e\u914d\u7f6e\u9879<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">7.1 \u6027\u80fd\u5bf9\u6bd4\u8868\u683c<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u65b9\u6848<\/th><th>\u4e8b\u52a1\u4e00\u81f4\u6027<\/th><th>\u5f00\u53d1\u590d\u6742\u5ea6<\/th><th>\u6027\u80fd\u5f00\u9500<\/th><th>\u9002\u7528\u573a\u666f<\/th><\/tr><\/thead><tbody><tr><td>Seata AT<\/td><td>\u5f3a\u4e00\u81f4\u6027<\/td><td>\u4f4e<\/td><td>\u4e2d<\/td><td>\u6570\u636e\u5e93\u5bc6\u96c6\u578b\u4e8b\u52a1<\/td><\/tr><tr><td>Seata TCC<\/td><td>\u5f3a\u4e00\u81f4\u6027<\/td><td>\u9ad8<\/td><td>\u4f4e<\/td><td>\u9ad8\u6027\u80fd\u8981\u6c42\uff0c\u9700\u624b\u52a8\u8865\u507f<\/td><\/tr><tr><td>RocketMQ \u4e8b\u52a1\u6d88\u606f<\/td><td>\u6700\u7ec8\u4e00\u81f4\u6027<\/td><td>\u4e2d<\/td><td>\u4f4e<\/td><td>\u4e8b\u4ef6\u9a71\u52a8\uff0c\u5f02\u6b65\u5904\u7406<\/td><\/tr><tr><td>\u02dcweb:20\u204a<\/td><td><\/td><td><\/td><td><\/td><td><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">7.2 \u914d\u7f6e\u9879\u5bf9\u6bd4\u8868\u683c<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u914d\u7f6e\u9879<\/th><th>Seata AT<\/th><th>RocketMQ \u4e8b\u52a1\u6d88\u606f<\/th><\/tr><\/thead><tbody><tr><td>\u4e8b\u52a1\u534f\u8c03<\/td><td>TC\uff08\u4e8b\u52a1\u534f\u8c03\u8005\uff09<\/td><td>Broker<\/td><\/tr><tr><td>\u56de\u6eda\u673a\u5236<\/td><td>undo_log\u81ea\u52a8\u56de\u6eda<\/td><td>\u4e8b\u52a1\u56de\u67e5<\/td><\/tr><tr><td>\u4f9d\u8d56\u7ec4\u4ef6<\/td><td>MySQL\u3001Nacos<\/td><td>RocketMQ\u3001NameServer<\/td><\/tr><tr><td>\u90e8\u7f72\u590d\u6742\u5ea6<\/td><td>\u4e2d\uff08\u9700\u90e8\u7f72Seata Server\uff09<\/td><td>\u4f4e\uff08\u4ec5\u9700RocketMQ\u96c6\u7fa4\uff09<\/td><\/tr><tr><td>\u02dcweb:20\u204a<\/td><td><\/td><td><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u516b\u3001\u4e2d\u9ad8\u7ea7\u5f00\u53d1\u8005\u7684\u5b9e\u7528\u89c1\u89e3<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u9009\u62e9\u5408\u9002\u7684\u5206\u5e03\u5f0f\u4e8b\u52a1\u65b9\u6848<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u4e1a\u52a1\u9700\u8981\u5f3a\u4e00\u81f4\u6027\uff08\u5982\u91d1\u878d\u573a\u666f\uff09\uff0c\u4f18\u5148\u9009\u62e9Seata AT\u6216TCC\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u8ffd\u6c42\u9ad8\u6027\u80fd\u548c\u6700\u7ec8\u4e00\u81f4\u6027\uff08\u5982\u7535\u5546\u8ba2\u5355\uff09\uff0cRocketMQ\u4e8b\u52a1\u6d88\u606f\u662f\u4f18\u9009\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u6027\u80fd\u4e0e\u4e00\u81f4\u6027\u7684\u6743\u8861<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u5f3a\u4e00\u81f4\u6027\u65b9\u6848\uff08\u5982Seata AT\uff09\u4f1a\u589e\u52a0\u9501\u5f00\u9500\uff0c\u9700\u7ed3\u5408\u4e1a\u52a1\u573a\u666f\u4f18\u5316\u6570\u636e\u5e93\u8bbe\u8ba1\u3002<\/li>\n\n\n\n<li>\u6700\u7ec8\u4e00\u81f4\u6027\u65b9\u6848\uff08\u5982RocketMQ\uff09\u9002\u5408\u9ad8\u5e76\u53d1\u573a\u666f\uff0c\u4f46\u9700\u8bbe\u8ba1\u5b8c\u5584\u7684\u8865\u507f\u673a\u5236\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>AI\u4e0e\u4e8b\u52a1\u7ba1\u7406\u7684\u7ed3\u5408<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>AI\u53ef\u7528\u4e8e\u9884\u6d4b\u4e8b\u52a1\u5931\u8d25\u6982\u7387\uff0c\u52a8\u6001\u8c03\u6574\u91cd\u8bd5\u7b56\u7565\u6216\u8d44\u6e90\u5206\u914d\u3002<\/li>\n\n\n\n<li>\u63a8\u8350\u63a2\u7d22<strong>Spring AI<\/strong>\uff08https:\/\/spring.io\/projects\/spring-ai\uff09\u4e0e\u4e8b\u52a1\u7ba1\u7406\u7684\u96c6\u6210\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u76d1\u63a7\u4e0e\u8fd0\u7ef4<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528Zipkin\u8ffd\u8e2a\u5206\u5e03\u5f0f\u4e8b\u52a1\u8c03\u7528\u94fe\uff0c\u5feb\u901f\u5b9a\u4f4d\u95ee\u9898\u3002<\/li>\n\n\n\n<li>\u7ed3\u5408Prometheus\u548cGrafana\uff0c\u5b9e\u65f6\u76d1\u63a7\u4e8b\u52a1\u6027\u80fd\uff0c\u786e\u4fdd\u7cfb\u7edf\u7a33\u5b9a\u6027\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e5d\u3001\u603b\u7ed3<\/h2>\n\n\n\n<p>\u5206\u5e03\u5f0f\u4e8b\u52a1\u662f\u5fae\u670d\u52a1\u67b6\u6784\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u73af\uff0cSeata\u548cRocketMQ\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u89e3\u51b3\u65b9\u6848\u3002Seata\u7684AT\u6a21\u5f0f\u901a\u8fc7\u81ea\u52a8\u5316\u7684undo_log\u673a\u5236\u964d\u4f4e\u4e86\u5f00\u53d1\u590d\u6742\u5ea6\uff0c\u9002\u5408\u6570\u636e\u5e93\u5bc6\u96c6\u578b\u573a\u666f\uff1bRocketMQ\u7684\u4e8b\u52a1\u6d88\u606f\u673a\u5236\u901a\u8fc7\u4e8b\u4ef6\u9a71\u52a8\u5b9e\u73b0\u6700\u7ec8\u4e00\u81f4\u6027\uff0c\u9002\u5408\u9ad8\u5e76\u53d1\u5f02\u6b65\u573a\u666f\u3002\u7ed3\u5408Spring Cloud Alibaba\u3001Docker\u548cAI\u6280\u672f\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u6784\u5efa\u9ad8\u6548\u3001\u53ef\u9760\u7684\u5206\u5e03\u5f0f\u7cfb\u7edf\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7\u672c\u6587\u7684\u4ee3\u7801\u793a\u4f8b\u548c\u4f18\u5316\u7b56\u7565\uff0c\u4e2d\u9ad8\u7ea7\u5f00\u53d1\u8005\u80fd\u591f\u5feb\u901f\u4e0a\u624b\u5206\u5e03\u5f0f\u4e8b\u52a1\u7684\u5b9e\u73b0\uff0c\u540c\u65f6\u6df1\u5165\u7406\u89e3\u5176\u539f\u7406\u548c\u6700\u4f73\u5b9e\u8df5\u3002\u672a\u6765\uff0c\u53ef\u8fdb\u4e00\u6b65\u63a2\u7d22AI\u5728\u4e8b\u52a1\u4f18\u5316\u548c\u76d1\u63a7\u4e2d\u7684\u5e94\u7528\uff0c\u63a8\u52a8Java\u540e\u7aef\u6280\u672f\u6808\u7684\u667a\u80fd\u5316\u53d1\u5c55\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>\u53c2\u8003\u8d44\u6599<\/strong>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Seata\u5b98\u65b9\u6587\u6863\uff1ahttps:\/\/seata.io<\/li>\n\n\n\n<li>RocketMQ\u5b98\u65b9\u6587\u6863\uff1ahttp:\/\/rocketmq.apache.org<\/li>\n\n\n\n<li>Spring Cloud Alibaba\uff1ahttps:\/\/spring.io\/projects\/spring-cloud-alibaba<\/li>\n\n\n\n<li>Unsplash\u56fe\u7247\u6765\u6e90\uff1ahttps:\/\/unsplash.com<\/li>\n<\/ul>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u5728\u5fae\u670d\u52a1\u67b6\u6784\u4e2d\uff0c\u7cfb\u7edf\u88ab\u62c6\u5206\u4e3a\u591a\u4e2a\u72ec\u7acb\u7684\u670d\u52a1\uff0c\u6bcf\u4e2a\u670d\u52a1\u53ef\u80fd\u62e5\u6709\u81ea\u5df1\u7684\u6570\u636e\u5e93\uff08\u5982MySQL\u3001PostgreSQL\u6216MongoDB\uff09\u3002\u8fd9 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[2,7],"tags":[],"class_list":["post-6597","post","type-post","status-publish","format-standard","hentry","category-java","category-spring-boot"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708.png","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708.png","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708.png","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708.png","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708.png","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708.png","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708.png","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708.png","post_all_images":[{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708.png","id":"image0"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034834708.png","id":"image1"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034820687.png","id":"image2"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034820687.png","id":"image3"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034814153.png","id":"image4"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034814153.png","id":"image5"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034813766.png","id":"image6"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929034813766.png","id":"image7"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"Java","post_date":"2025-09-30","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230519082947553.jpg","avatarurls":[],"related_posts":null,"pageviews":350,"next_post_id":6605,"next_post_title":"Spring Boot + sshd-sftp\uff1aSSH \u547d\u4ee4\u4e0e\u6587\u4ef6\u4f20\u8f93\u5b9e\u8df5","previous_post_id":6736,"previous_post_title":"\u57fa\u4e8e Java \u4e0e YOLOv8 \u5b9e\u73b0\u8868\u683c\u56fe\u50cf\u884c\u5217\u68c0\u6d4b\u7684\u5b8c\u6574\u5b9e\u8df5","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/6597","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=6597"}],"version-history":[{"count":1,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/6597\/revisions"}],"predecessor-version":[{"id":6602,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/6597\/revisions\/6602"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=6597"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=6597"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=6597"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}