INT-4192: Improve ExprEvaluatingReleaseStrategy

JIRA: https://jira.spring.io/browse/INT-4192

To avoid implicit overhead for loading messages from persistent message store, use entire `MessageGroup` as root object for expression evaluation context

Also see https://github.com/spring-projects/spring-integration/wiki/Spring-Integration-4.3-to-5.0-Migration-Guide
This commit is contained in:
Artem Bilan
2017-03-07 17:54:13 -05:00
committed by Gary Russell
parent b3f461e139
commit d3fb8b8f9e
7 changed files with 44 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@ import org.springframework.integration.store.SimpleMessageGroup;
* @author Alex Peters
* @author Dave Syer
* @author Gary Russell
* @author Artem Bilan
*
*/
public class ExpressionEvaluatingReleaseStrategyTests {
@@ -56,14 +57,14 @@ public class ExpressionEvaluatingReleaseStrategyTests {
@Test
public void testCompletedWithFilterSpelEvaluated() throws Exception {
strategy = new ExpressionEvaluatingReleaseStrategy("!?[payload==5].empty");
strategy = new ExpressionEvaluatingReleaseStrategy("!messages.?[payload==5].empty");
strategy.setBeanFactory(mock(BeanFactory.class));
assertThat(strategy.canRelease(messages), is(true));
}
@Test
public void testCompletedWithFilterSpelReturnsNotCompleted() throws Exception {
strategy = new ExpressionEvaluatingReleaseStrategy("!?[payload==6].empty");
strategy = new ExpressionEvaluatingReleaseStrategy("!messages.?[payload==6].empty");
strategy.setBeanFactory(mock(BeanFactory.class));
assertThat(strategy.canRelease(messages), is(false));
}

View File

@@ -43,13 +43,13 @@
<aggregator input-channel="groupTimeoutExpressionAggregatorInput" output-channel="output" discard-channel="discard"
send-partial-result-on-expiry="true"
group-timeout-expression="size() ge 2 ? 100 : -1"
release-strategy-expression="[0].headers.sequenceNumber == [0].headers.sequenceSize"/>
release-strategy-expression="messages[0].headers.sequenceNumber == messages[0].headers.sequenceSize"/>
<aggregator input-channel="zeroGroupTimeoutExpressionAggregatorInput" output-channel="output" discard-channel="discard"
send-partial-result-on-expiry="true"
send-timeout="10"
group-timeout-expression="@bool.getAndSet(true) ? 0 : 10"
release-strategy-expression="[0].headers.sequenceNumber == [0].headers.sequenceSize"/>
release-strategy-expression="messages[0].headers.sequenceNumber == messages[0].headers.sequenceSize"/>
<beans:bean id="bool" class="java.util.concurrent.atomic.AtomicBoolean" />

View File

@@ -12,7 +12,7 @@
<!--Auction scenario-->
<scatter-gather input-channel="inputAuction" output-channel="output" scatter-channel="auctionChannel">
<gatherer release-strategy-expression="^[payload gt 5] != null or size() == 3"/>
<gatherer release-strategy-expression="messages.^[payload gt 5] != null or size() == 3"/>
</scatter-gather>
<task:executor id="threadPoolTaskExecutor" pool-size="10"/>
@@ -34,7 +34,7 @@
<recipient channel="distribution2Channel"/>
<recipient channel="distribution3Channel"/>
</scatterer>
<gatherer release-strategy-expression="^[payload gt 5] != null or size() == 3"/>
<gatherer release-strategy-expression="messages.^[payload gt 5] != null or size() == 3"/>
</scatter-gather>
<channel id="gatherChannel">
@@ -55,7 +55,7 @@
<gateway id="gateway" default-request-channel="gatewayAuction"/>
<scatter-gather input-channel="gatewayAuction" scatter-channel="auctionChannel">
<gatherer release-strategy-expression="^[payload gt 5] != null or size() == 3"/>
<gatherer release-strategy-expression="messages.^[payload gt 5] != null or size() == 3"/>
</scatter-gather>
<chain input-channel="scatterGatherWithinChain" output-channel="output">