定义事件
 
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;
    }
}
 
发布事件
 
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);
        }
    }
}