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