讲清事务边界和消息重试
日英对照例句
看中文试着说,再展开核对日语和英语。
订单更新和待发送事件记录在同一个事务里写入。
- 日语
- 注文の更新と送信待ちイベントの記録は、同じトランザクション内で書き込みます。
- 英语
- We write the order update and the pending event in the same database transaction.
后台任务在事务提交后发布事件。
- 日语
- トランザクションのコミット後に、バックグラウンド処理がイベントを送信します。
- 英语
- A background job publishes the event after the transaction commits.
发送失败时,任务之后会重试。
- 日语
- 送信に失敗した場合は、バックグラウンド処理が後で再試行します。
- 英语
- If publishing fails, the job retries later.
消费者用事件 ID 避免重复处理。
- 日语
- 受信側はイベントIDを使って、重複処理を防ぎます。
- 英语
- The consumer uses the event ID to avoid processing the same event twice.
背诵与复述
同一事务 → 提交后发布 → 重试 → 消费者去重
核对日英背诵稿
- 日语
- 注文の更新と送信待ちイベントの記録は、同じトランザクション内で書き込みます。トランザクションのコミット後に、バックグラウンド処理がイベントを送信します。送信に失敗した場合は、バックグラウンド処理が後で再試行します。受信側はイベントIDを使って、重複処理を防ぎます。
- 英语
- We write the order update and the pending event in the same database transaction. A background job publishes the event after the transaction commits. If publishing fails, the job retries later. The consumer uses the event ID to avoid processing the same event twice.
工作追问
数据库已提交,但消息发布失败了。用一分钟解释会发生什么。