rocketmq 動態設置topic和consumerGroup


 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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM