@Component
public class AopAspect {
@Autowired
private AmqpTemplate template1;
public void beforeAdvice(JoinPoint joinPoint) {
String s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
template1.convertAndSend("defaultQueue",s);
System.out.println("向消息队列发送消息" + s);
}
public void afterAdvice(JoinPoint joinPoint){
Object o = template1.receiveAndConvert("defaultQueue");
System.out.println("向队列消费消息" + o.toString());
}
}
springAOP的配置
原文:http://blog.51cto.com/12165865/2178963