Description
In what version(s) of Spring Integration are you seeing this issue?
6.1.2
Describe the bug
When using a JdbcMessageStore
and one group completes (or expires), the group is removed. This removal also removes the messages that were linked to that group, even when the same message is still linked to other groups.
The link (int_group_to_message
) for that other group is not removed, so there's a mapping entry to a message that no longer exists in the database. Also, the size attribute of the other group is not updated, so it still shows a count that suggests the message is still present, while it can't be retrieved via getMessages()
or streamMessages()
To Reproduce
Set up two flows listening on different channels. Both flows have an aggregator and use the JdbcMessageStore
. Define different release strategies for each flow, but make sure there is an overlap in the "required messages" for each flow.
Now send the message that is required in both flows to both channels. After that, send a message that completes one of the groups. Then send a message that should complete the other group. It will not complete, since the first message is now missing from the group.
Expected behavior
The message should only be deleted from the int_message
table, when it's not linked to any other group.
Sample
https://github.com/nschoellhorn/spring-integration-jdbc-repro
In SpringIntegrationJdbcReproApplication, I have implemented a CommandLineRunner that simulates the flow of events/messages as described above.
The flow setup can be found in Flows.kt
The Release strategy has some logging that should visualize the problem:
If my assumption is correct that this is a bug, I would be happy to assist in providing a patch to achieve the expected behavior.