fix(be): fix msg type definition for check & judge AMQP and add excep…#3574
fix(be): fix msg type definition for check & judge AMQP and add excep…#3574zero1177 wants to merge 2 commits into
Conversation
…tion for undefined msg case
There was a problem hiding this comment.
Pull request overview
Updates the backend AMQP subscriber implementations to align with the updated @golevelup/nestjs-rabbitmq createSubscriber handler typings, and adds explicit handling for undefined message payloads in judge/check consumers.
Changes:
- Adds
createSubscriber<object>()generics and updates handler signatures tomsg: T | undefinedandrawMessage?: ConsumeMessage. - Introduces Nack handling when
msgis undefined for both judge and check subscribers. - Uses optional access for AMQP message properties to match the library’s updated optional parameter typing.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request improves type safety in the AMQP services by replacing 'any' with 'ConsumeMessage' and adding generic types to subscribers. It also adds validation for empty messages in both JudgeAMQPService and CheckAMQPService. The reviewer pointed out that using the default 'Nack()' for empty messages causes infinite requeues and suggested using 'Nack(false)' to prevent poison message loops.
Description
@golevelup/nestjs-rabbitmq 라이브러리 업데이트로 createSubscriber 타입 정의가 변경되어 기존 check & judge AMQP Service에 적용했습니다.
현재 라이브러리 타입 정의
구체적인 변경사항
createSubscriber<object>()제네릭을 추가해, subscriber가 정상적으로 수신하는 메시지의 payload 타입을object로 명시했습니다.(전 커밋에 올렸던
raw?: ConsumeMessage로 타입을 명시하는 방식은 백엔드와 직접 Dependency가 아닌 amqplib를 import해야 해서, pnpm 환경에서 빌드가 깨질 수 있다고 해 이렇게 다시 변경했습니다)msg가 undefined인 경우 예외 처리를 통해, 비어있는 judge/check 메시지를 Nack 처리하도록 추가했습니다. 이런 케이스의 메세지는 requeue하지 않는다는 의도를 명시하도록 Nack(false)로 변경했습니다.