spring-integrationaggregator

Spring-Integration AggregatingMessageHandler.setGroupTimeoutExpression visibility


My business logic needs to be able to change configured group timeout on a aggregator.

The code looks like this:

@Autowired
AggregatingMessageHandler messageAggregator;

public void setTimeout(Integer timeoutValue) {
    Expression timeoutExpression = new SpelExpressionParser().parseExpression(timeoutValue.toString());
    messageAggregator.setGroupTimeoutExpression(timeoutExpression);
}

The problem is:

Possible solution scenarios:


Solution

  • Not sure why you call it as a bug, but your requirement isn't standard.

    Let's try to come up with some solution together!

    Since you are going to change group-timeout at runtime and you really don't need an expression, bacause your value is just Integer, you can use org.springframework.integration.expression.ValueExpression as a value of the AtomicReference bean.

    In this case you can simply show the current value to the user:

    @Autowired
    private AtomicReference<ValueExpression> groupTimeoutExpression;
    
    ....
       this.groupTimeoutExpression.get().getValue();
    

    And use that AtomicReference with a new ValueExpression for the current value and set the last one to the AggregatingMessageHandler.

    On the application startup you should do the same for initial group-timeout. Or just copy/paste your value to the group-timeout attribute of the <aggregator> and for the AtomicReference bean.

    HTH