Spring integration Spring集成AggregatingMessageHandler.setGroupTimeoutExpression可见性
我的业务逻辑需要能够更改聚合器上配置的组超时 代码如下所示:Spring integration Spring集成AggregatingMessageHandler.setGroupTimeoutExpression可见性,spring-integration,aggregator,Spring Integration,Aggregator,我的业务逻辑需要能够更改聚合器上配置的组超时 代码如下所示: @Autowired AggregatingMessageHandler messageAggregator; public void setTimeout(Integer timeoutValue) { Expression timeoutExpression = new SpelExpressionParser().parseExpression(timeoutValue.toString()); message
@Autowired
AggregatingMessageHandler messageAggregator;
public void setTimeout(Integer timeoutValue) {
Expression timeoutExpression = new SpelExpressionParser().parseExpression(timeoutValue.toString());
messageAggregator.setGroupTimeoutExpression(timeoutExpression);
}
问题是:
- 我想向用户显示当前值,但是
- 这个
- 我应该在这个bean上注入一个表达式,然后改变它的值吗,
- 也就是说,它将在下次构建消息组时使用新结果重新计算表达式
- 我应该用自己的具有公共setter的处理程序扩展AggregatingMessageHandler吗
- 或者这是一个bug,应该在下一个版本中修复
组超时
,并且确实不需要表达式
,因为您的值只是整数
,所以可以使用org.springframework.integration.expression.ValueExpression
作为原子引用
bean的值
在这种情况下,您只需向用户显示当前值
:
@Autowired
private AtomicReference<ValueExpression> groupTimeoutExpression;
....
this.groupTimeoutExpression.get().getValue();
@Autowired
私有原子引用groupTimeoutExpression;
....
this.groupTimeoutExpression.get().getValue();
并将该AtomicReference
与新的ValueExpression
一起用于当前值,并将最后一个值设置为AggregatingMessageHandler
在应用程序启动时,您应该对初始组超时执行相同的操作。或者只需将值
复制/粘贴到
的组超时
属性和原子引用
bean
HTH但我不想扩展AggregatingMessageHandler。顺便说一句,我通过context.xml将其实例化为,但我没有说要extensingaggregatingmessagehandler
。我刚才指出在运行时使用ValueExpression
,并利用AtomicReference
提供一个钩子,向最终用户公开当前的组超时值。您可以继续使用setGroupTimeoutExpression
,无需扩展。对不起,我不清楚。