0

In my SpringBoot application I have written an aggregator as below. I want messages to be release immediately after 2 minutes has lapsed. But below code does not seem to work. However, when release-strategy is changed from "timoutReleaseStrategy' to "size() ==1" , messages are release one by one. However, I want all messages to be released after 2 minutes.

The spring version i am using is 5.3.20

<int:aggregator 
      output-channel="splitterInChannel"
      send-partial-result-on-expiry="true"
      message-store="customMessageStore"
      correlation-strategy-expression="headers['type']
      ref="taskAggregationService"
      method="aggregateTask"
      release-strategy-expression="timeoutReleaseStrategy"    
      expire-groups-upon-completion="true"
      expire-groups-upon-timeout="true"
      id="customAggregator"
      input-channel="aggregatorInChannel" >
</int:aggregator>

<bean id="customMessageStore"  class="org....SimpleMessageStore"/>
<bean id="timeoutReleaseStrategy" class="org....TimeoutCountSequenceSizeReleaseStrategy">
   <constructor-arg name="threshold" value="100"/>
      <constructor-arg name="timeout" value="120000"/> // 2 minutes
</bean>
Nichole
  • 189
  • 2
  • 7

1 Answers1

1

See group-timeout option of the aggregator. The point is that ReleaseStrategy takes an action only when a message is received by the aggregator. In your case there is no enough messages for a group to trigger release action. Therefore we have to schedule respective task per group essentially making an aggregator as an active component and do something even if no messages sent in time.

See more info in docs: https://docs.spring.io/spring-integration/docs/current/reference/html/message-routing.html#agg-and-group-to

And also consider to upgrade to the latest version: https://spring.io/projects/spring-integration#learn

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118