diff --git a/spring-integration-core/src/main/java/org/springframework/integration/store/AbstractMessageGroupStore.java b/spring-integration-core/src/main/java/org/springframework/integration/store/AbstractMessageGroupStore.java
index e69cfd4c05..414fc2bcff 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/store/AbstractMessageGroupStore.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/store/AbstractMessageGroupStore.java
@@ -26,6 +26,7 @@ import org.springframework.integration.support.DefaultMessageBuilderFactory;
import org.springframework.integration.support.MessageBuilderFactory;
import org.springframework.integration.support.utils.IntegrationUtils;
import org.springframework.jmx.export.annotation.ManagedAttribute;
+import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.messaging.Message;
@@ -107,6 +108,7 @@ public abstract class AbstractMessageGroupStore extends AbstractBatchingMessageG
}
@Override
+ @ManagedOperation
public synchronized int expireMessageGroups(long timeout) {
int count = 0;
long threshold = System.currentTimeMillis() - timeout;
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/store/MessageGroupStore.java b/spring-integration-core/src/main/java/org/springframework/integration/store/MessageGroupStore.java
index edc46d1b1c..df2877c004 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/store/MessageGroupStore.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/store/MessageGroupStore.java
@@ -17,6 +17,7 @@ import java.util.Collection;
import java.util.Iterator;
import org.springframework.jmx.export.annotation.ManagedAttribute;
+import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.messaging.Message;
/**
@@ -101,6 +102,7 @@ public interface MessageGroupStore extends BasicMessageGroupStore {
*
* @see #registerMessageGroupExpiryCallback(MessageGroupCallback)
*/
+ @ManagedOperation
int expireMessageGroups(long timeout);
/**
@@ -145,7 +147,7 @@ public interface MessageGroupStore extends BasicMessageGroupStore {
/**
* Invoked when a MessageGroupStore expires a group.
*/
- public interface MessageGroupCallback {
+ interface MessageGroupCallback {
void execute(MessageGroupStore messageGroupStore, MessageGroup group);
diff --git a/spring-integration-core/src/main/resources/org/springframework/integration/config/spring-integration-4.3.xsd b/spring-integration-core/src/main/resources/org/springframework/integration/config/spring-integration-4.3.xsd
index b5021dee6b..3f7627ed9d 100644
--- a/spring-integration-core/src/main/resources/org/springframework/integration/config/spring-integration-4.3.xsd
+++ b/spring-integration-core/src/main/resources/org/springframework/integration/config/spring-integration-4.3.xsd
@@ -3739,7 +3739,7 @@
Specifies whether messages that expired should be aggregated and sent to the 'output-channel' or 'replyChannel'.
Messages are expired when their containing MessageGroup expires. One of the ways of expiring MessageGroups is by
configuring a MessageGroupStoreReaper. However MessageGroups can alternatively be expired by simply calling
- MessageGroupStore.expireMessageGroup(groupId). That could be accomplished via a ControlBus operation
+ MessageGroupStore.expireMessageGroups(timeout). That could be accomplished via a ControlBus operation
or by simply invoking that method if you have a reference to the MessageGroupStore instance.
diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorWithMessageStoreParserTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorWithMessageStoreParserTests-context.xml
index 8a2781a4e0..c80a20a8ad 100644
--- a/spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorWithMessageStoreParserTests-context.xml
+++ b/spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorWithMessageStoreParserTests-context.xml
@@ -14,10 +14,12 @@
-
+
+
+
diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorWithMessageStoreParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorWithMessageStoreParserTests.java
index 6eb6fdb24a..0fd26b82f4 100644
--- a/spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorWithMessageStoreParserTests.java
+++ b/spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorWithMessageStoreParserTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2010 the original author or authors.
+ * Copyright 2002-2016 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.
@@ -26,31 +26,36 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.store.MessageGroupStore;
import org.springframework.integration.support.MessageBuilder;
+import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Dave Syer
+ * @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
+@DirtiesContext
public class AggregatorWithMessageStoreParserTests {
-
+
@Autowired
@Qualifier("input")
private MessageChannel input;
-
+
@Autowired
private TestAggregatorBean aggregatorBean;
-
+
@Autowired
private MessageGroupStore messageGroupStore;
+ @Autowired
+ private MessageChannel controlBusChannel;
+
@Test
@DirtiesContext
public void testAggregation() {
-
input.send(createMessage("123", "id1", 3, 1, null));
assertEquals(1, messageGroupStore.getMessageGroup("id1").size());
input.send(createMessage("789", "id1", 3, 3, null));
@@ -67,12 +72,11 @@ public class AggregatorWithMessageStoreParserTests {
@Test
@DirtiesContext
public void testExpiry() {
-
input.send(createMessage("123", "id1", 3, 1, null));
assertEquals(1, messageGroupStore.getMessageGroup("id1").size());
input.send(createMessage("456", "id1", 3, 2, null));
assertEquals(2, messageGroupStore.getMessageGroup("id1").size());
- messageGroupStore.expireMessageGroups(-10000);
+ this.controlBusChannel.send(new GenericMessage