Event和Handler异步处理事件
1.定义事件Event类
@Getter
@Setter
public class PushMsgEvent {
//该类包含一系列信息
private Test test;
public PushBillIdentifyEvent(Test test) {
this.test= test;
}
}
2.定义事件处理类
@Slf4j
@EventHandler
public class PushMsgEventHandler {
@Autowired
private ExeService exeService;
//异步事件处理
@Handler(delivery = Invoke.Asynchronously)
public void pushMsg(PushMsgEvent event){
//检查信息的状态
MsgStatusEnum enum = exeService.check(event)
switch(enum){
case NORMAL:
//DO A;
break;
case ABNORMAL:
//DO B;
break;
default:
log.error("【{}】异常",event.getNo());
}
}
}