itwanger / itwanger/paicoding

[Refactor] 重构 RabbitMQ 模块:引入 Spring AMQP 替代原生 Client

Open
#125 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Java
Stars
3.2k
Forks
622
PR merge metrics
No merged PRs in 30d

Description

issue类型

  • 功能优化

当前问题

1. 原生 Client 维护成本高
  • 需手动创建管理连接池
  • 消费者使用 while(true) 轮询
  • 无多消费者并发能力
2. 缺少消息可靠性保障
  • 生产端:消息发送后无回调机制,无法确认消息是否成功到达 Exchange 或 Queue
  • 消费端:缺乏死信机制
3. 其他问题
  • 无消费幂等性,可能重复消费

解决方案

1. 引入Spring AMQP 替代原生 RabbitMQ Client
  • 利用 Spring Boot 自动配置管理 ConnectionFactory 和 CachingConnectionFactory
  • 使用 @RabbitListener 注解驱动,替代轮询拉取模式,实现推模式消费
  • 配置并发消费
2. 配置死信队列和失败补偿
  • 配置 Publisher Confirm 和 Publisher Return,并记录 log.error
  • 配置死信队列
3. 使用锁
  • 在消费端利用 Redis (SETNX + TTL) 记录 Message ID 或业务 Key,防止重复消费

详细信息已分享在知识星球🌏:https://articles.zsxq.com/id_6fu347bbecgh.html

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by locating the existing native RabbitMQ connection, producer, and consumer code, then review the requested Spring AMQP, reliability, dead-letter, and Redis locking requirements. Done means the module uses the described listener, confirmation, failure-compensation, dead-letter, concurrency, and duplicate-consumption safeguards.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, rabbitmq, redis, spring-boot
Domain
backend, distributed-systems
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.