Free queue channel in spring integration with java DSL

后端 未结 1 726
清歌不尽
清歌不尽 2021-01-23 10:40

i have a channel that stores messages. When new messages arrive, if the server has not yet processed all the messages (that still in the queue), i need to clear the queue (for e

相关标签:
1条回答
  • 2021-01-23 11:13

    I would suggest you to take a look into a purge API of the QueueChannel:

    /**
     * Remove any {@link Message Messages} that are not accepted by the provided selector.
     * @param selector The message selector.
     * @return The list of messages that were purged.
     */
    List<Message<?>> purge(@Nullable MessageSelector selector);
    

    This way with a custom MessageSelector you will be able to remove from the queue old messages. See a timestamp message header to consult. With the result of this method you can do whatever you need to do with old messages.

    0 讨论(0)
提交回复
热议问题