-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
In what version(s) of Spring Integration are you seeing this issue?
5.3.1.RELEASE
Describe the bug
If you have set up a DelayHandler using a ConfigurableDbMessageStore and the MongoDB collection behind it is very big (e.g. 1M records), upon startup the DelayHandler will try to re-schedule all messages in the delay store. Because we are using ConfigurableDbMessageStore which extends AbstractMessageGroupStore and also lazyLoadMessageGroups, this class, sets the persistentMessageGroupFactory as a SimpleMessageGroupFactory(SimpleMessageGroupFactory.GroupType.PERSISTENT) which returns PersistentMessageGroup. When the PersistentMessageGroup is called to retrieve the messages, it loads ALL messages in memory before returning the iterator
Line 171 in 0831657
private final class PersistentCollection extends AbstractCollection<Message<?>> { |
Line 186 in 0831657
this.collection = PersistentMessageGroup.this.messageGroupStore.getMessagesForGroup(groupId); |
Line 217 in 0831657
public Iterator<Message<?>> iterator() { |
Line 598 in 0831657
public void onApplicationEvent(ContextRefreshedEvent event) { |
Line 570 in 0831657
MessageGroup messageGroup = this.messageStore.getMessageGroup(this.messageGroupId); |
Depending on the available memory, OOM happens.
To Reproduce
Create a collection behind the DelayHandler/ConfigurableDbMessageStore and load it with millions of records. Start an application that makes use of the DelayHandler
Expected behavior
We believe it is OK to reschedule messages upon startup but not loading them all at once in memory. Maybe doing it via MongoDB streaming API?