简体   繁体   中英

how to change mule's imap mail fetch order?

I have an IMAP connection to fetch emails using Mule. I'm running into an issue.

Here are my 2 simple requirements:

  1. I want to fetch emails in reverse order. (latest first)
  2. Ignore SEEN messages but don't delete them.

I was looking at the code that mule (3.3.1) uses: org.mule.transport.email.RetrieveMessageReceiver.poll().

The code seems to be fetching messages from message 1.

348: Message[] messages = folder.getMessages(1, batchSize);

The messages fetched here are processed in a loop in :

org.mule.transport.email.RetrieveMessageReceiver.messagesAdded(MessageCountEvent)

142: if (!messages[i].getFlags().contains(Flags.Flag.DELETED)
143:      && !messages[i].getFlags().contains(Flags.Flag.SEEN))

What this whole logic is doing is that it is trying to read OLD unread messages. The code comes back to line 348 and executes

folder.getMessages(1, batchSize);

again, and gets the same messages and it keeps on waiting. How can i change the order of fetch.

FYI: Using MS Exchange for IMAP

Not sure why you say that Mule tried to read "OLD unread messages"? It actually just tries to read unread messages, ie not DELETED nor SEEN.

Anyway, theoretically the Mulesque way of sorting the messages would be to use resequencer . Unfortunately the mail message receivers do not set any of the required control properties to let Mule process the received messages as a single batch so that won't work.

So the only solution I can think of is to extend org.mule.transport.email.RetrieveMessageReceiver and register your custom version on the IMAP connector with a <service-overrides /> child element.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM