java有没有办法在Spring中将ApplicationEventPublisher与延迟事件一起使用?
我需要使用事件驱动机制。使用ApplicationEventPublisher
。我希望在到达侦听此事件的端点之前为消息设置延迟。有这样的方法吗?找到https://docs.spring.io/spring-integration/docs/2.0.0.RC1/reference/html/delayer.html,但不确定它应如何与ApplicationEventPublisher集成
有没有一种简单的方法可以使用spring实现上述功能
# 1 楼答案
除了
Delayer
之外,Spring集成还基于传入消息向ApplicationEventPublisher
提供ApplicationEventPublishingMessageHandler
到生产者的ApplicationEvent
。这样,您将真正延迟<delayer>
中的消息(事件),然后通过<int-event:outbound-channel-adapter>
将事件发布到应用程序也应考虑尽可能使用后期Spring集成版本:https://projects.spring.io/spring-integration/