GH-8732 Don't remove JDBC message if other groups (#8733)
* GH-8732 Don't remove JDBC message if other groups Fixes https://github.com/spring-projects/spring-integration/issues/8732 When same message is added into different groups, its record in the `INT_MESSAGE` must remain until the last group is removed * Improve `JdbcMessageStore.DELETE_MESSAGES_FROM_GROUP` SQL to ignore those messages for removal which has other group records in the `INT_GROUP_TO_MESSAGE` table **Cherry-pick to `6.1.x`, `6.0.x` & `5.5.x`** * * Fix `JdbcMessageStore.removeMessage()` and `removeMessagesFromGroup()` to remove from `INT_MESSAGE` only if there is no other records in `INT_GROUP_TO_MESSAGE` * * Improve `MessageStore.removeMessage()` Javadoc mentioning `MessageGroupStore` specifics
This commit is contained in:
@@ -497,6 +497,36 @@ public class MySqlJdbcMessageStoreTests implements MySqlContainerTest {
|
||||
assertThat(this.messageStore.getMessageGroup(groupId).getCondition()).isEqualTo("testCondition");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sameMessageInTwoGroupsNotRemovedByFirstGroup() {
|
||||
GenericMessage<String> testMessage = new GenericMessage<>("test data");
|
||||
|
||||
messageStore.addMessageToGroup("1", testMessage);
|
||||
messageStore.addMessageToGroup("2", testMessage);
|
||||
|
||||
messageStore.removeMessageGroup("1");
|
||||
|
||||
assertThat(messageStore.getMessageCount()).isEqualTo(1);
|
||||
|
||||
messageStore.removeMessageGroup("2");
|
||||
|
||||
assertThat(messageStore.getMessageCount()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeMessagesFromGroupDontRemoveSameMessageInOtherGroup() {
|
||||
GenericMessage<String> testMessage = new GenericMessage<>("test data");
|
||||
|
||||
messageStore.addMessageToGroup("1", testMessage);
|
||||
messageStore.addMessageToGroup("2", testMessage);
|
||||
|
||||
messageStore.removeMessagesFromGroup("1", testMessage);
|
||||
|
||||
assertThat(messageStore.getMessageCount()).isEqualTo(1);
|
||||
assertThat(messageStore.messageGroupSize("1")).isEqualTo(0);
|
||||
assertThat(messageStore.messageGroupSize("2")).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
public static class Config {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user