This is a general question of how to release the resources used in ReleaseStrategy. I'm referring to the response submitted here for example - I was wondering what is the recommended strategy for cleaning the map used in the example if something went wrong:
private final Map<Object, AtomicInteger>() map = new HashMap<>();
Use case: 990 out of 1000 group messages (or 9 out of 10 as in the referred example) were received but then a timeout elapsed (we are not interested in partial result)... How would you clean the map values for this particular groupId or in general: what would be the best approach to release any other resources used in ReleaseStrategy?
I was thinking of some expiring maps or maybe triggering bean cleanUp method from the outside... But maybe there is some suggested way to handle these cases?
Maybe I'm not getting how exactly ReleaseStrategy works in case of groupTimeout, so I have the below example config:
group-timeout="1000" discard-channel="discardChannel"
end-partial-result-on-expiry="false" release-strategy="xxx"
Let say I have a group of 10 messages produced by the splitter, each message is really some job to be accomplished by the thread pool executor. So if any (let say the second job) of the jobs execution pool takes longer than the specified group-timeout, this particular message will be send to the discardChannel but the ReleaseStrategy will be called as well, right?
But in such a case do I still get the MessageGroup updated within that discarded message? I assume not - so the canRelease method invocation can be greater than the group.getMessages().size(), right?
What is happening now? What with this one message that was received before the timeout elapsed? Is this the situation that I still can decide if I want to release this one message that is within the MessageGroup? What with 8 remaining messages (jobs), do they belong to the new groupId after the second message from the group was discarded (I assume that expire-groups-upon-timeout is set to true by default), so do these 8 messages get a new groupId and are being sent to ReleaseStrategy as well?
Other question is what will happen when canRelease method returns only false (having the above configuration) - I've noticed that although I'm getting the info like below:
Expiring MessageGroup with correlationKey[36293c73-6f66-4a1a-8824-9d5268e07081]
Expiring MessageGroup with correlationKey[36293c73-6f66-4a1a-8824-9d5268e07081]
messages are "being returned" to the ServiceActivator (jobs executor pool bean) in such a case? So it is executed again and again in such cases so I cannot exit the workflow?