【问题标题】:Is there a way to use ApplicationEventPublisher with delayed event in Spring?有没有办法在 Spring 中使用 ApplicationEventPublisher 和延迟事件?
【发布时间】:2017-10-30 08:34:33
【问题描述】:

我需要使用事件驱动机制。使用ApplicationEventPublisher。我想在到达收听此事件的端点之前为消息设置延迟。有没有这样的方法?找到了https://docs.spring.io/spring-integration/docs/2.0.0.RC1/reference/html/delayer.html,但不确定它应该如何与 ApplicationEventPublisher 集成。

有没有简单的方法使用spring来实现上述?

【问题讨论】:

    标签: java spring spring-mvc spring-integration spring-messaging


    【解决方案1】:

    除了Delayer,Spring Integration 还根据传入的消息为生产者提供ApplicationEventPublishingMessageHandlerApplicationEventPublisherApplicationEvent。这样你真的会延迟<delayer>中的消息(一个事件),然后通过<int-event:outbound-channel-adapter>向应用程序发布一个事件。

    还要考虑尽可能使用较晚的 Spring Integration 版本:https://projects.spring.io/spring-integration/

    【讨论】:

      猜你喜欢
      • 2020-08-31
      • 2016-02-17
      • 2012-12-30
      • 2016-11-13
      • 1970-01-01
      • 1970-01-01
      • 2020-11-20
      • 2017-08-26
      • 1970-01-01
      相关资源
      最近更新 更多