in rocketmq-v5-client-spring-boot/src/main/java/org/apache/rocketmq/client/autoconfigure/ExtConsumerResetConfiguration.java [83:109]
private void registerTemplate(String beanName, Object bean) {
Class<?> clazz = AopProxyUtils.ultimateTargetClass(bean);
if (!RocketMQClientTemplate.class.isAssignableFrom(bean.getClass())) {
throw new IllegalStateException(clazz + " is not instance of " + RocketMQClientTemplate.class.getName());
}
org.apache.rocketmq.client.annotation.ExtConsumerResetConfiguration annotation = clazz.getAnnotation(org.apache.rocketmq.client.annotation.ExtConsumerResetConfiguration.class);
GenericApplicationContext genericApplicationContext = (GenericApplicationContext) applicationContext;
validate(annotation, genericApplicationContext);
SimpleConsumerBuilder consumerBuilder = null;
SimpleConsumer simpleConsumer = null;
SimpleConsumerInfo simpleConsumerInfo = null;
try {
final ClientServiceProvider provider = ClientServiceProvider.loadService();
SimpleConsumerBuilder simpleConsumerBuilder = provider.newSimpleConsumerBuilder();
simpleConsumerInfo = createConsumer(annotation, simpleConsumerBuilder);
} catch (Exception e) {
log.error("Failed to startup SimpleConsumer for RocketMQTemplate {}", beanName, e);
}
RocketMQClientTemplate rocketMQTemplate = (RocketMQClientTemplate) bean;
rocketMQTemplate.setSimpleConsumerBuilder(consumerBuilder);
rocketMQTemplate.setSimpleConsumer(simpleConsumer);
rocketMQTemplate.setMessageConverter(rocketMQMessageConverter.getMessageConverter());
log.info("Set real simpleConsumer {} to {}", simpleConsumerInfo, beanName);
}