Allow events to trigger the creation of MessageGroup in MessageGroupStore [INT-2208]
Tony Jordan opened INT-2208 and commented
Splitters (for example) should be able to trigger the creation of a MessageGroup with a given correlationID. This would allow the action of splitting to prompt a the creation of a new MessageGroup in a specified MessageStore. An aggregator downstream using that MessageStore would "expect" messages and timeouts on that group would begin. If no messages ever arrive, the reaper will still expire the group after the timeout and a workflow could handle the situation as needed.
Affects: 2.1 M3
Issue Links:
- #6575 Time-based ReleaseStrategy
Oleg Zhurakousky commented
We are going to address it for 2.2. And we already have another request which could be solved by resolving this issue: http://forum.springsource.org/showthread.php?126969-Is-this-a-use-case-for-an-aggregator
Oleg Zhurakousky commented
I just thought about something. Seems to me like a cross cutting concern and can exists anywhere May be all we need is tow write a configurable and specialized ChannelInterceptor (e.g., GroupCreatingChannelInterceptor) and even hid its details behind the namespace. So for the default configuration we would have something like this:
<int:channel id="myChannel" >
<int:interceptors>
<int:group-creator message-store="msRef"/>
</int:interceptors>
</int:channel>
The above would create message group looking for a default 'corelationId' headers in the Message.
Or you can specify your own header
<int:channel id="myChannel" >
<int:interceptors>
<int:group-creator message-store="msRef" expression="headers.myCorrelationId"/>
</int:interceptors>
</int:channel>
What I like about this approach is that it seems very intuitive to me from the cutting concern perspective hence the Channel Interceptors. And most importantly you can do it now if you chose to write your own grop creator.
Oleg Zhurakousky commented
We'll be addressing it in the first milestone of 3.0 which should be out before SpringOne
Gary Russell commented
See also: http://forum.springsource.org/showthread.php?139534-Question-about-MessageGroupStoreReaper-timeout
It's not clear to me this will help because there will be nothing to discard for a "reaped" empty group.
Maybe we could add an Application event for reaped groups and an <event:inbound-channel-adapter/> can consume it.
Artem Bilan commented
We should keep in mind here that our MessageGroupStore implementations don't allow to create empty groups: it is created by first addMessageToGroup. And even MongoDB implementation doesn't have separate document for MessageGroup entity - group metadata is stored within each MessageDocument.
Gary, can you explain how event from expiration may be useful?
Artem Bilan commented
See Scatter-Gather use-case: https://stackoverflow.com/questions/69458917/scatter-gather-with-parallel-flow-timeout-in-aggregator.
So, it scatters (distributes) the message and is ready for reply. Unfortunately currently its gatherer part starts working only when the first message arrives and exactly this moment is treated as group timeout creation point, when we are interested in exactly the moment when we scatter the message.
Artem Bilan commented
We have a MessageTriggerAction contract. So, an aggregator ca implement it and react respectively: take a correlationKey and create an empty group.
We might need to revise MessageGroupStore impls to see if they allow to create empty groups.
My MongoDB comment might be out-dated already according to the current state of code.