I've got a JEE application with some performance issues. I suspect that it is due to MQ listeners (MessageDrivenBeans) that are not executing enough threads concurrently and figured that an easy way to validate my theory would be to write a quick Aspect to profile the number of threads being triggered at the same time.
I'm using LTW in the rest of my application, so trying to use LTW for this aspect as well.
While my Aspect works in theory, it seems to be advising the "wrong" beans; that is- it is picking out what seem to be container generated beans instead of my primary beans, and consequently, it is providing false information. The 5 listeners that I want to advise extend a common Abstract class which implements the onMessage() method. I'm trying to advise this method for all beans.
My Aspect is as follows:
@Aspect("pertypewithin(business.security.tables.mq.*)")
public class ListenerThreadLoggingAspect {
// get a static slf4j logger for the class
protected static final Logger logger = getLogger(ListenerThreadLoggingAspect.class);
private static AtomicInteger concurrentThreadCount = new AtomicInteger(0);
// pointcut to pick out the onMessage() method
@Pointcut("execution(!synthetic * (*..mq.AbstractSecurityAccessTableListener+ && !*..mq.AbstractSecurityAccessTableListener).onMessage(..))")
public void onMessagePointcut() {
}
@Around("onMessagePointcut()")
public Object logThreadCount(ProceedingJoinPoint pjp) throws Throwable {
// entering message handler, so increment threads and log
int concurrentThreads = concurrentThreadCount.incrementAndGet();
logger.debug("ID[{}]: Start [{}]. Concurrent Threads: {}", System.identityHashCode(this), pjp.getTarget().getClass().getName(), concurrentThreads);
// execute the listener
Object result = pjp.proceed();
// done so decrement number of threads
concurrentThreads = concurrentThreadCount.decrementAndGet();
logger.trace("ID[{}]: Stop [{}]. Concurrent Threads: {}", System.identityHashCode(this), pjp.getTarget().getClass().getName(), concurrentThreads);
return result;
}
}
While the weaver indicates that the correct classes are being woven, the execution shows a different trace: