You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
INT-4550: Disallow multi aggregators on same MGS (#2622)
* INT-4550: Disallow multi aggregators on same MGS
JIRA: https://jira.spring.io/browse/INT-4550
**Cherry-pick to 5.0.x**
* * Introduce `UniqueExpiryCallback`
* Use `UniqueExpiryCallback` in the `AbstractCorrelatingMessageHandler`
* Check for uniqueness in the `AbstractMessageGroupStore`
* Remove duplicate code in the `ConfigurableMongoDbMessageStore`
* * Fix tests according a new logic
* * Address PR review
* Change `Assert.isTrue` to the `logger.error` for backward compatibility
* Revert changes in tests since we don't throw exception anymore
* Fix language on doc
* * Fix Checkstyle violation in the `AbstractMessageGroupStore`
* * Ignore `testDontReapMessageOfOtherHandler()`
Copy file name to clipboardExpand all lines: spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractCorrelatingMessageHandler.java
Copy file name to clipboardExpand all lines: spring-integration-core/src/main/java/org/springframework/integration/store/AbstractMessageGroupStore.java
+13-5Lines changed: 13 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ public abstract class AbstractMessageGroupStore extends AbstractBatchingMessageG
Copy file name to clipboardExpand all lines: spring-integration-core/src/test/java/org/springframework/integration/aggregator/AbstractCorrelatingMessageHandlerTests.java
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -425,6 +425,7 @@ public void testScheduleRemoveAnEmptyGroupAfterConfiguredDelay() throws Exceptio
425
425
}
426
426
427
427
@Test
428
+
@Ignore("Until 5.2 with new 'owner' feature on groups")
Copy file name to clipboardExpand all lines: spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageStore.java
Copy file name to clipboardExpand all lines: src/reference/asciidoc/aggregator.adoc
+7Lines changed: 7 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -812,6 +812,13 @@ The callback has direct access to the store and the message group so that it can
812
812
The `MessageGroupStore` maintains a list of these callbacks, which it applies, on demand, to all messages whose timestamps are earlier than a time supplied as a parameter (see the `registerMessageGroupExpiryCallback(..)` and `expireMessageGroups(..)` methods, described earlier).
813
813
For more detail, see <<reaper>>.
814
814
815
+
IMPORTANT: It is important not to use the same `MessageGroupStore` instance in different aggregator components, when you intend to rely on the `expireMessageGroups` functionality.
816
+
Every `AbstractCorrelatingMessageHandler` registers its own `MessageGroupCallback` based on the `forceComplete()` callback.
817
+
This way each group for expiration may be completed or discarded by the wrong aggregator.
818
+
Starting with version 5.0.10, a `UniqueExpiryCallback` is used from the `AbstractCorrelatingMessageHandler` for the registration callback in the `MessageGroupStore`.
819
+
The `MessageGroupStore`, in turn, checks for presence an instance of this class and logs an error with an appropriate message if one is already present in the callbacks set.
820
+
This way the Framework disallows usage of the `MessageGroupStore` instance in different aggregators/resequencers to avoid the mentioned side effect of expiration the groups not created by the particular correlation handler.
821
+
815
822
You can call the `expireMessageGroups` method with a timeout value.
816
823
Any message older than the current time minus this value is expired and has the callbacks applied.
817
824
Thus, it is the user of the store that defines what is meant by message group "`expiry`".
0 commit comments