Feat/replace spring event with rabbitmq#210
Open
maixiaowen111 wants to merge 5 commits into
Open
Conversation
新增 spring-boot-starter-amqp 依赖、交换机/队列配置、EventPublisher 核心发布器 - RabbitMQConfig: 1 个 Exchange + 5 个 Queue + 7 个 Binding - EventPublisher: TransactionSynchronization.afterCommit 保证事务后投递 - application.yml: RabbitMQ 连接配置 + 消费重试
8 处 publishEvent() 改为 eventPublisher.publish(),利用事务同步保证消息投递 - ArticleServiceImpl: 3 处替换(发布/删除/状态变更) - CommentServiceImpl: 1 处替换 - FollowServiceImpl: 1 处替换 - PortfolioServiceImpl: 2 处替换(增改/删除) - RedisTokenManager: 1 处替换(非事务直接发送)
5 个 Handler 改为 RabbitMQ 消费,业务逻辑保持不变 - ArticleHandler: 统一入口 + instanceof 分发 3 种事件类型 - CommentHandler/FollowHandler/AccountHandler/PortfolioHandler: 1:1 替换
修复 CI FOSSA 许可证合规检查,本次改动涉及的 6 个包中 所有 .java 文件现在均包含 Copyright (c) 2020 RYMCU MIT 声明 影响包:config / event / handler / handler/event / service/impl / auth
maixiaowen111
force-pushed
the
feat/replace-spring-event-with-rabbitmq
branch
from
July 10, 2026 10:37
93c4aa9 to
9302ac6
Compare
修复 CI FOSSA 许可证合规检查剩余的 26 个问题 src/test/ 下所有 Java 测试文件现在包含 Copyright (c) 2020 RYMCU MIT 声明
Author
|
@ronger-x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🐰 将 Spring Event 替换为 RabbitMQ 消息队列
动机
当前项目使用 Spring Event + @TransactionalEventListener 处理异步任务(Lucene 索引更新、通知推送等),存在以下问题:
改动内容
spring-boot-starter-amqp依赖RabbitMQConfig:1 个 Exchange + 5 个 Queue + 7 个 BindingEventPublisher:TransactionSynchronization.afterCommit() 保证事务后投递架构对比
改造前:Service → ApplicationEventPublisher → @TransactionalEventListener (同步/同进程)
改造后:Service → RabbitMQ Exchange → Queue → @RabbitListener (异步/解耦/可重试)
测试方法