INT-3420 Aggregator expire-groups-upon-timeout
JIRA: https://jira.spring.io/browse/INT-3420 Add option to allow the empty group to remain after timeout so late arriving messages can be discarded. INT-3420 Add Callout Hyperlinks The aggregator configuration documentation had hyperlinks from the attribute descriptions to the attribute in the XML, but not vice-versa. For a large number of attributes such as this, bi-directional hyperlinks are useful. INT-3420 Doc Polishing
This commit is contained in:
committed by
Artem Bilan
parent
e21d32f4fd
commit
40f1122df2
@@ -13,9 +13,13 @@
|
||||
|
||||
package org.springframework.integration.aggregator;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -237,6 +241,38 @@ public class AggregatorTests {
|
||||
assertEquals("ABC", this.expiryEvents.get(0).getGroupId());
|
||||
assertEquals(2, this.expiryEvents.get(0).getMessageCount());
|
||||
assertEquals(false, this.expiryEvents.get(0).isDiscarded());
|
||||
Message<?> message3 = createMessage(5, "ABC", 3, 3, replyChannel, null);
|
||||
this.aggregator.handleMessage(message3);
|
||||
assertEquals(1, this.store.getMessageGroup("ABC").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGroupRemainsAfterTimeout() throws InterruptedException {
|
||||
this.aggregator.setSendPartialResultOnExpiry(true);
|
||||
this.aggregator.setExpireGroupsUponTimeout(false);
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
QueueChannel discardChannel = new QueueChannel();
|
||||
this.aggregator.setDiscardChannel(discardChannel);
|
||||
Message<?> message1 = createMessage(3, "ABC", 3, 1, replyChannel, null);
|
||||
Message<?> message2 = createMessage(5, "ABC", 3, 2, replyChannel, null);
|
||||
this.aggregator.handleMessage(message1);
|
||||
this.aggregator.handleMessage(message2);
|
||||
this.store.expireMessageGroups(-10000);
|
||||
Message<?> reply = replyChannel.receive(1000);
|
||||
assertNotNull("A reply message should have been received", reply);
|
||||
assertEquals(15, reply.getPayload());
|
||||
assertEquals(1, expiryEvents.size());
|
||||
assertSame(this.aggregator, expiryEvents.get(0).getSource());
|
||||
assertEquals("ABC", this.expiryEvents.get(0).getGroupId());
|
||||
assertEquals(2, this.expiryEvents.get(0).getMessageCount());
|
||||
assertEquals(false, this.expiryEvents.get(0).isDiscarded());
|
||||
assertEquals(0, this.store.getMessageGroup("ABC").size());
|
||||
Message<?> message3 = createMessage(5, "ABC", 3, 3, replyChannel, null);
|
||||
this.aggregator.handleMessage(message3);
|
||||
assertEquals(0, this.store.getMessageGroup("ABC").size());
|
||||
Message<?> discardedMessage = discardChannel.receive(1000);
|
||||
assertNotNull("A message should have been discarded", discardedMessage);
|
||||
assertSame(message3, discardedMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.integration.config;
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
@@ -121,6 +122,7 @@ public class AggregatorParserTests {
|
||||
Object handler = context.getBean("aggregatorWithExpressions.handler");
|
||||
assertSame(mbf, TestUtils.getPropertyValue(handler, "outputProcessor.messageBuilderFactory"));
|
||||
assertSame(mbf, TestUtils.getPropertyValue(handler, "outputProcessor.processor.messageBuilderFactory"));
|
||||
assertTrue(TestUtils.getPropertyValue(handler, "expireGroupsUponTimeout", Boolean.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -145,15 +147,16 @@ public class AggregatorParserTests {
|
||||
releaseStrategy, accessor.getPropertyValue("releaseStrategy"));
|
||||
assertEquals("The AggregatorEndpoint is not injected with the appropriate CorrelationStrategy instance",
|
||||
correlationStrategy, accessor.getPropertyValue("correlationStrategy"));
|
||||
Assert.assertEquals("The AggregatorEndpoint is not injected with the appropriate output channel",
|
||||
assertEquals("The AggregatorEndpoint is not injected with the appropriate output channel",
|
||||
outputChannel, accessor.getPropertyValue("outputChannel"));
|
||||
Assert.assertEquals("The AggregatorEndpoint is not injected with the appropriate discard channel",
|
||||
assertEquals("The AggregatorEndpoint is not injected with the appropriate discard channel",
|
||||
discardChannel, accessor.getPropertyValue("discardChannel"));
|
||||
Assert.assertEquals("The AggregatorEndpoint is not set with the appropriate timeout value", 86420000l,
|
||||
assertEquals("The AggregatorEndpoint is not set with the appropriate timeout value", 86420000l,
|
||||
TestUtils.getPropertyValue(consumer, "messagingTemplate.sendTimeout"));
|
||||
Assert.assertEquals(
|
||||
assertEquals(
|
||||
"The AggregatorEndpoint is not configured with the appropriate 'send partial results on timeout' flag",
|
||||
true, accessor.getPropertyValue("sendPartialResultOnExpiry"));
|
||||
assertFalse(TestUtils.getPropertyValue(consumer, "expireGroupsUponTimeout", Boolean.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
release-strategy="releaseStrategy"
|
||||
correlation-strategy="correlationStrategy"
|
||||
send-timeout="86420000"
|
||||
send-partial-result-on-expiry="true"/>
|
||||
send-partial-result-on-expiry="true"
|
||||
expire-groups-upon-timeout="false"/>
|
||||
|
||||
<channel id="aggregatorWithExpressionsInput"/>
|
||||
<channel id="aggregatorWithExpressionsOutput"/>
|
||||
|
||||
Reference in New Issue
Block a user