apache / rocketmq-spring

Apache RocketMQ Spring Integration
https://rocketmq.apache.org/
Apache License 2.0
2.11k stars 896 forks source link

Make enableMsgTrace configurable with RocketMQMessageListener and ExtRocketMQTemplateConfiguration #548

Open tongtaodragon opened 1 year ago

tongtaodragon commented 1 year ago
  1. Please describe the feature you are requesting. We want to make enableMsgTrace configurable through application.yml file as below. @RocketMQMessageListener( topic = "normal_topic_define_in_Aliware_MQ", consumerGroup = "group_define_in_Aliware_MQ", selectorExpression = "${demo.consumer.selector}", enableMsgTrace = "${demo.consumer.enableMsgTrace}" // hope configure like this ) public class ACLStringConsumer implements RocketMQListener {

@ExtRocketMQTemplateConfiguration( nameServer = "${demo.rocketmq.extNameServer}", tlsEnable = "${demo.rocketmq.ext.useTLS}", enableMsgTrace = "${demo.consumer.enableMsgTrace}" // hope configure like this ) public class ExtRocketMQTemplate extends RocketMQTemplate { }

  1. Provide any additional detail on your proposed use case for this feature. enableMsg is important to identify the message source and consumer. But it may bring performance issue. We don't want to turn off the feature totally through server side configuration. We want to control it from producer client or consumer client when we met performance issue indeed.

  2. Indicate the importance of this issue to you (blocker, must-have, should-have, nice-to-have). Are you currently using any workarounds to address this issue? should-have. No workaround, we have to hard code true or false in RocketMQMessageListener and ExtRocketMQTemplateConfiguration annotation.

RongtongJin commented 1 year ago

I think it makes sense. Does anyone want to fix this issue?

Sunstreaker commented 1 year ago

Please assign this to me, will put forward a pr later !

Sunstreaker commented 1 year ago

@RongtongJin I am looking at the code now. At first glance it looks like to we need to change the 'enableMsgTrace' property from boolean to string to assign the spring expression so that the code can evaluate the expression "${demo.consumer.enableMsgTrace}" to get the boolean value using the 'PropertyResolver.resolvePlaceholders'.

this is a contract change at RocketMQMessageListener and ExtRocketMQTemplateConfiguration by changing the enableMsgTrace property datatype from boolean to string.

Can I go forward to change the property datatype? Trying to understand the impact of changing the datatype