Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with Spring Integration Aggregator group-timeout value

We are using Spring Integration 4.2.3 Aggregator component and defined group-timeout and expecting the group to be timed out within the given timeout value while adding messages to the group & release size criteria is not met.

But we are seeing different results, when we input heavy load to the service the aggregator is waiting on all messages to be added to the group rather than expiring the group when the timeout reached.

Is there any way to override the aggregator functionality to look at the first message rather than last message when timing out group.

like image 878
Satish Kumar Avatar asked Jun 17 '26 04:06

Satish Kumar


1 Answers

Well, actually you can do what you need even now. Using the same group-timeout-expression. But you have to consult the #root object of the evaluation context which is exactly what you need - MessageGroup. With that you can call one of for your purpose:

/**
 * @return the timestamp (milliseconds since epoch) associated with the creation of this group
 */
long getTimestamp();

/**
 * @return the timestamp (milliseconds since epoch) associated with the time this group was last updated
 */
long getLastModified();

Therefore an expression for your original request might be like:

group-timeout-expression="timestamp + 10000 - T(System).currentTimeMillis()"

And we get that adjusted timeout which will be applied to scheduled task with the value like: new Date(System.currentTimeMillis() + groupTimeout));.

like image 142
Artem Bilan Avatar answered Jun 19 '26 13:06

Artem Bilan