You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "kevinWangSheng (via GitHub)" <gi...@apache.org> on 2024/08/07 09:08:42 UTC
[I] [Bug] Use the plusar and spring aop ,the aop failed [pulsar]
kevinWangSheng opened a new issue, #23135:
URL: https://github.com/apache/pulsar/issues/23135
### 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!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug] Use the plusar and spring aop ,the aop failed [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari closed issue #23135: [Bug] Use the plusar and spring aop ,the aop failed
URL: https://github.com/apache/pulsar/issues/23135
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org