Prior to Spring Integration 4.0, the aggregator was a completely passive component. Group release (or not) is triggered by the arrival of a new message - when the release strategy is consulted to see if the group to which the message belongs can be released. So, how do we discard (or release) a group that is idle and has had no new messages arrive for some time?
The reaper runs on a schedule and can detect "stuck" groups and release them based on time without a new message arriving.
It is also used to remove empty groups - the aggregator can be configured so that empty groups remain present so that late arriving messages can be discarded instead of forming a new group. Empty groups can be reaped on a different schedule to partially complete groups.
The reaper expires all groups that meet the configured criteria; if the group passes the criteria, it is expired; otherwise it is not, and will be considered the next time the reaper runs. The action taken by the reaper (partial release, discard etc) depends on other settings on the aggregator.
Spring Integration 4.0 introduced new attributes (group-timeout
and group-timeout-expression
), allowing partial groups to be released automatically after the timeout, without a reaper (the timer is armed when a new message arrives for a group). The reaper can still be used to expire (remove) empty groups in this case.
I hope that explains the function of the reaper.