度量标准生成要涵盖的方法:
@Override
@Metric(metricName = "rmq.onMessage", type = { MetricType.METER, MetricType.HISTOGRAM })
public void onMessage(Object messageBytes) {
//some processing
}
此处的注册方法:
MessageListenerAdapter listenerAdapter = new MessageListenerAdapter(messageConsumer, "onMessage");
如果队列中有任何消息,那么将使用以下命令调用onMessage:
protected Object invokeListenerMethod(String methodName, Object[] arguments, Message originalMessage)
throws Exception {
try {
MethodInvoker methodInvoker = new MethodInvoker();
methodInvoker.setTargetObject(getDelegate());
methodInvoker.setTargetMethod(methodName);
methodInvoker.setArguments(arguments);
methodInvoker.prepare();
return methodInvoker.invoke();
}
我的长相:
@Around("@annotation(myAnnotation.graphite.annotations.Metric)")
public Object graphiteAspect(ProceedingJoinPoint joinPoint) {
//metrics reporting done here
}