[ISSUE #632 ] Fix NPE caused by using @ ExtRocketMQTemplateConfiguration annotation extension to send messages #634
+51
−9
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.
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