我们有一个 Spring Integration 上下文,其中包含 2 个聚合器、一些转换器、适配器等... 此上下文正在使用来自 ActiveMQ 队列以及 2 个 Web 服务的消息,并将它们放入聚合器中。 我们想要实现的是,每次在具体队列中收到消息时,我们都会重置聚合器中的所有消息,并在每个有状态组件中启动每个批处理过程(由队列中的启动消息触发)完全空白和干净.
那么,如何根据队列中收到的消息重置聚合器组件?
最佳答案
我不清楚您的用例,但您想要得到的可以使用 MessageGroupStoreReaper
实现:
* Convenient configurable component to allow explicit timed expiry of {@link MessageGroup} instances in a
* {@link MessageGroupStore}. This component provides a no-args {@link #run()} method that is useful for remote or timed
* execution and a {@link #destroy()} method that can optionally be called on shutdown.
如果您为聚合器的 MessageGroupStore
配置它,它将执行从那里注册的回调:
store.registerMessageGroupExpiryCallback(
(messageGroupStore, group) -> this.forceReleaseProcessor.processMessageGroup(group));
如果您不在聚合器上配置任何其他内容,您的消息将被丢弃(默认为 NullChannel
),并且群组将从存储中删除。
因此,当该类型的消息到达时,您应该调用 MessageGroupStoreReaper.run()
,然后才将其发送到进程中。
关于java - 一种重置 Spring Integration 上下文中所有消息的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42351032/