Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #632 ] Fix NPE caused by using @ ExtRocketMQTemplateConfiguration annotation extension to send messages #634

Merged
merged 1 commit into from
Mar 3, 2024

Conversation

lilinjiang
Copy link
Contributor

@lilinjiang lilinjiang commented Feb 26, 2024

What is the purpose of the change
Close #632

问题现象:
修复应用启动时,监听RocketMQ消息后使用@ExtRocketMQTemplateConfiguration注解扩展的RocketMQTemplate发送消息导致的空指针异常问题。
问题原因:
Listener 启动时机比 @ExtRocketMQTemplateConfiguration注解扩展的RocketMQTemplate中producer 实例化的早,导致Listener监听到消息时 RocketMQTemplate中producer 还未实例化,此时使用未实例化producer属性的RocketMQTemplate发送消息将导致空指针异常。
(@RocketMQMessageListener 与 Spring Cloud Stream 的生产者一起使用时同样存在一样的问题,都是因为Listener的启动时机太早)
解决方案:
推迟了Listener 的启动时机 详情见commits

…Template发送消息导致空指针异常问题。

问题原因:
Listener 启动时机比 @ExtRocketMQTemplateConfiguration注解扩展的RocketMQTemplate中producer 实例化的早,导致Listener监听到消息时 RocketMQTemplate中producer 还未实例化,此时使用未实例化producer属性的RocketMQTemplate发送消息将导致空指针异常。
(@RocketMQMessageListener 与 Spring Cloud Stream 的生产者一起使用时同样存在一样的问题,都是因为Listener的启动时机太早)
@lilinjiang lilinjiang changed the title 修复应用启动时,使用@ExtRocketMQTemplateConfiguration注解扩展的RocketMQTemplate发送消息导致的空指针异常问题。 [ISSUE #632 ] 修复应用启动时,使用@ExtRocketMQTemplateConfiguration注解扩展的RocketMQTemplate发送消息导致的空指针异常问题。 Feb 26, 2024
@lilinjiang lilinjiang changed the title [ISSUE #632 ] 修复应用启动时,使用@ExtRocketMQTemplateConfiguration注解扩展的RocketMQTemplate发送消息导致的空指针异常问题。 [ISSUE #632 ] 修复使用@ExtRocketMQTemplateConfiguration注解扩展的RocketMQTemplate发送消息导致的空指针异常问题。 Feb 26, 2024
@lilinjiang
Copy link
Contributor Author

@panzhi33

@panzhi33
Copy link
Contributor

panzhi33 commented Mar 1, 2024

@panzhi33

@panzhi33

Please help to see if the v5 client also has this problem. If so, please help to submit a PR to fix it.

@RongtongJin RongtongJin changed the title [ISSUE #632 ] 修复使用@ExtRocketMQTemplateConfiguration注解扩展的RocketMQTemplate发送消息导致的空指针异常问题。 [ISSUE #632 ] Fix NPE caused by using @ ExtRocketMQTemplateConfiguration annotation extension to send messages Mar 3, 2024
@RongtongJin RongtongJin merged commit b03f552 into apache:master Mar 3, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RocketMQ监听者收到消息后发送到其他Topic时报空指针异常
3 participants