diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractCorrelatingMessageHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractCorrelatingMessageHandler.java index 9f59680872..56fdb89581 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractCorrelatingMessageHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractCorrelatingMessageHandler.java @@ -83,6 +83,7 @@ import org.springframework.util.CollectionUtils; * @author Artem Bilan * @author David Liu * @author Enrique Rodriguez + * * @since 2.0 */ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageProducingHandler @@ -432,9 +433,9 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP completedMessages = this.completeGroup(message, correlationKey, messageGroup); } finally { - // Always clean up even if there was an exception - // processing messages - this.afterRelease(messageGroup, completedMessages); + // Possible clean (implementation dependency) up + // even if there was an exception processing messages + afterRelease(messageGroup, completedMessages); } if (!isExpireGroupsUponCompletion() && this.minimumTimeoutForEmptyGroups > 0) { removeEmptyGroupAfterTimeout(messageGroup, this.minimumTimeoutForEmptyGroups); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AggregatingMessageHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AggregatingMessageHandler.java index de82cd3b93..b1fb34177e 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AggregatingMessageHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AggregatingMessageHandler.java @@ -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.messaging.Message; * @author Oleg Zhurakousky * @author Artem Bilan * @author Gary Russell + * * @since 2.1 */ public class AggregatingMessageHandler extends AbstractCorrelatingMessageHandler { @@ -66,6 +67,12 @@ public class AggregatingMessageHandler extends AbstractCorrelatingMessageHandler return this.expireGroupsUponCompletion; } + /** + * Complete the group and remove all its messages. + * If the {@link #expireGroupsUponCompletion} is true, then remove group fully. + * @param messageGroup the group to clean up. + * @param completedMessages The completed messages. Ignored in this implementation. + */ @Override protected void afterRelease(MessageGroup messageGroup, Collection> completedMessages) { Object groupId = messageGroup.getGroupId(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/ResequencingMessageHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/ResequencingMessageHandler.java index 212042d7b1..c60ffebb86 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/ResequencingMessageHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/ResequencingMessageHandler.java @@ -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. @@ -30,6 +30,7 @@ import org.springframework.messaging.Message; * @author Oleg Zhurakousky * @author Gary Russell * @author Artem Bilan + * * @since 2.1 */ public class ResequencingMessageHandler extends AbstractCorrelatingMessageHandler { @@ -75,6 +76,13 @@ public class ResequencingMessageHandler extends AbstractCorrelatingMessageHandle afterRelease(messageGroup, completedMessages, false); } + /** + * Perform group removal if its {@code size} is equal to the {@code sequenceSize}. + * Remove {@code completedMessages} from the group if it isn't null. + * @param messageGroup the group to clean up. + * @param completedMessages The completed messages. + * @param timeout True if the release/discard was due to a timeout. + */ @Override protected void afterRelease(MessageGroup messageGroup, Collection> completedMessages, boolean timeout) { int size = messageGroup.size();