Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.15.3
-
None
-
Patch Available
-
Novice
Description
URI option mapMailMessage=true as is the default with Mail Component fetches IMAP-messages without peek=true option. This results to faulty rollback logic since in case of an exception and rollback, messages are already marked with flag SEEN and won't be rolled back to UNSEEN.
Messages are marked with peek-option in processBatch-method but mapping mail messages to Camel messages happens before that method call in createExchanges-method.
I've attached a patch where peek option is set to the messages already in the poll-method which resolves the issue. Unfortunately I couldn't write a proper jUnit test for this scenario since org.jvnet.mock_javamail.Mailbox doesn't seem to support marking messages as SEEN even if they have been fetched. However, I have attached traces of faulty and fixed run with a test route (that route is also included).