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
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.