定义事件
package com.amarsoft.lease.mail.event;
import org.springframework.context.ApplicationEvent;
public class TestEvent extends ApplicationEvent {
private String flowId;
public TestEvent (Object source, String flowId) {
super(source);
this.flowId = flowId;
}
public String getFlowId() {
return flowId;
}
public void setFlowId(String flowId) {
this.flowId = flowId;
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
发布事件
applicationContext.publishEvent(new TestEvent(flowId, flowId));
监听事件
@Slf4j
@Component
public class BillSendFlowMailListener {
@TransactionalEventListener
public void sendBillSendFlowMail(BillSendFlowMailEvent event) {
String flowId = event.getSource().toString();
try {
}catch (Exception e) {
log.error("事件测试,flowId" + flowId, e);
}
}
}