【发布时间】:2018-07-23 07:09:39
【问题描述】:
我正在寻找一种将两个参数传递给@EventListener 的方法。我有一个Event 课程。它看起来像这样:
public class Event {
String id;
Date timestamp;
String data;
String type;
}
data被序列化了,类型描述了如何反序列化。
目前,我反序列化事件数据,然后通过 `ApplicationEventPublisher 发布反序列化的 EventData 子类实例,如下所示:
public void listen(Event event) throws IOException {
EventData eventData = converter.toEventData(event);
eventPublisher.publishEvent(eventData);
}
到目前为止,这运行良好,但现在我需要访问我的侦听器中的事件和数据。有没有办法将两个参数传递给@EventListener?
【问题讨论】:
标签: spring spring-boot spring-4 event-sourcing