首页 > 其他 > 详细

rocketmq 动态设置topic和consumerGroup

时间:2021-05-12 20:37:11      阅读:146      评论:0      收藏:0      [点我收藏+]
 1 @Override
 2 public void afterPropertiesSet() throws Exception {
 3     final RocketMQMessageListener annotation = MyConsumer.class.getAnnotation(RocketMQMessageListener.class);
 4     InvocationHandler h = Proxy.getInvocationHandler(annotation);
 5     Field hField = h.getClass().getDeclaredField("memberValues");
 6     hField.setAccessible(true);
 7     Map memberValues = (Map) hField.get(h);
 8     memberValues.put("topic", topic);
 9     memberValues.put("consumerGroup", consumerGroup);
10 }
11 此时 topic  consumerGroup 就可以通过配置中心或者文件来动态配置
12 比如:
13 @Value("${dynamic.spring.rocketmq.topic}"
14 private String topic

 

rocketmq 动态设置topic和consumerGroup

原文:https://www.cnblogs.com/zt1991jskj/p/14700219.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!