GitHub user kevinWangSheng edited a discussion: Use the pulsar and spring aop ,the aop failed
### Search before asking - [X] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar. ### Read release policy - [X] I understand that unsupported versions don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker. ### Version windwos 10 64x jdk8 pulsar:2.1 ### Minimal reproduce step does it support spring aop ? ### What did you expect to see? i want to go to the aspcet @Pointcut("@within(com.ak.cepf.mybatis.aspect.IgnoreTenant) ||@annotation(com.ak.cepf.mybatis.aspect.IgnoreTenant)") public void pointcut() { } @Around("pointcut()") public Object around(ProceedingJoinPoint point) throws Throwable { Object var9; try { Class<?> targetClass = point.getTarget().getClass(); IgnoreTenant classIgnoreTenant = (IgnoreTenant)targetClass.getAnnotation(IgnoreTenant.class); MethodSignature signature = (MethodSignature)point.getSignature(); Method method = signature.getMethod(); IgnoreTenant methodIgnoreTenant = (IgnoreTenant)method.getAnnotation(IgnoreTenant.class); boolean isClassAnnotated = AnnotationUtils.isAnnotationDeclaredLocally(IgnoreTenant.class, targetClass); boolean isMethodAnnotated = Objects.nonNull(methodIgnoreTenant); if (isClassAnnotated) { MybatisTenantContext.set(classIgnoreTenant.isIgnore()); } if (isMethodAnnotated) { MybatisTenantContext.set(methodIgnoreTenant.isIgnore()); } var9 = point.proceed(); } finally { MybatisTenantContext.clear(); } return var9; } and config like that : @PulsarConsumer(topic = "cepf_listing_change", subscriptionName = "cepf_statistics", serverName = "amsPulsar", clazz = byte[].class, initialPosition = SubscriptionInitialPosition.Latest, serialization = Serialization.BYTE, deadLetterTopic = "cepf_listing_change-dlq", maxRedeliverCount = 3 ) // 不走租户 @IgnoreTenant // todo 消费供货价改变消息 public void consumeSupplyPriceChangeMessage(PulsarMessage<byte[]> message){ try { log.info("[orderItemPriceChange] messageId:{},message{}",message.getMessageId(),message); MessageDTO messageDto = JSONObject.parseObject(message.getValue(), MessageDTO.class); if(ObjectUtil.isEmpty(messageDto)){ return; } supplyPriceChangeRepairService.repairItemsCommonPriceAmount(messageDto); } catch (Exception e) { // 放到死信队列进行重试 log.warn("[orderItemPriceChange] 消费失败,进行重试:{}", JSON.toJSONString(message)); e.printStackTrace(); throw e; } } the PulsarConsumer is depend on pulsar ### What did you see instead? I debug and don't see go to the code: @Pointcut("@within(com.ak.cepf.mybatis.aspect.IgnoreTenant) ||@annotation(com.ak.cepf.mybatis.aspect.IgnoreTenant)") public void pointcut() { } @Around("pointcut()") public Object around(ProceedingJoinPoint point) throws Throwable { Object var9; try { Class<?> targetClass = point.getTarget().getClass(); IgnoreTenant classIgnoreTenant = (IgnoreTenant)targetClass.getAnnotation(IgnoreTenant.class); MethodSignature signature = (MethodSignature)point.getSignature(); Method method = signature.getMethod(); IgnoreTenant methodIgnoreTenant = (IgnoreTenant)method.getAnnotation(IgnoreTenant.class); boolean isClassAnnotated = AnnotationUtils.isAnnotationDeclaredLocally(IgnoreTenant.class, targetClass); boolean isMethodAnnotated = Objects.nonNull(methodIgnoreTenant); if (isClassAnnotated) { MybatisTenantContext.set(classIgnoreTenant.isIgnore()); } if (isMethodAnnotated) { MybatisTenantContext.set(methodIgnoreTenant.isIgnore()); } var9 = point.proceed(); } finally { MybatisTenantContext.clear(); } return var9; } ### Anything else? i guess it doesn't support spring aop ? i know it's threapool is not registry to spring? so i doesn't support it? i want to know why. ### Are you willing to submit a PR? - [X] I'm willing to submit a PR! GitHub link: https://github.com/apache/pulsar/discussions/23148 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected]
