in our project a simple flow should read mails from an imap mailserver and process those… sounds simple, but isnt… the mails need to be left on the server for further use… and it is not guaranteed, that no other user might access the mailbox with an other client and do stuff… so no save SEEN, UNSEEN states… the imapUid is used to identify the mail…
ok simple task with mule… just take the imap:connector… wrong! the imap:connector is a cool connector to read unseen mails of an mailbox and returns a MimeMessage object, which does not contain the imapUid… so bla… unusable in our case… but the checkFrequency is a really important feature, because we dont know how many mails are in the inbox and a frontend-triggered start command is unusable, because of the delay… so we need an other solution: build it…
simple as well… wrong again!… ok not really wrong, but complicated… we use a quartz:inbound_endpoint to trigger the flow… a MailFetcher class is called, which gets all the needed information and… ehm… ok here is the problem… the quartz:inbound_endpoint sends one start command into the flow… the MailFetcher gets all the mails and sends them to the next workflow… but i really want single mails in the next flow and not a list of mails… so… how the hell can this be done? FilteringListMessageSplitter is the solution… or lets say looked like…
FilteringListMessageSplitter accepts a List as a message payload then routes list elements as messages over an endpoint where the endpoint’s filter accepts the payload. (link)
actually it is the solution… but this class only has for services… and not for flows… for flows: <collection-splitter>
The Collection Splitter acts on messages whose payload is a Collection type. It sends each member of the collection to the next message processor as separate messages. (link)
which really works…
And with an correct test environment it would be a peace of cake to figure it out… but returning null instead of a java.util.List might be a problem to split…